WooCommerce: Display Different Widgets Based On Product Category

Using Widget Logic, you can easily set what widget you want to display based on what WooCommerce product categories users are browsing.

For example, you can set what widgets users will see when he will land to the “Book” product category page. These widgets will not be visible in other pages, it will be only shown to a user when he lands to that exact category.

Let’s see how we can set a widget which will only be visible to certain WooCommerce product category:

  1. Download and install Widget Logic
  2. Now, Go to Appearance -> Widgets and add the widgets to your sidebar
  3. You’ll find a new “Widget Logic” field added at the bottom of every widget
  4. Go to Product -> Categories
  5. Select the category and copy what’s written on the Slug field
  6. Since you want to display these widgets only on WooCommerce category pages, write is_product_category() in widget logic field
  7. Paste the category slug, if you want to display widgets only on one category. Like this is_product_category( ‘clothing’ )
  8. Click on Save

Using Widget Logic along with WordPress and WooCommerce Conditional tags you can set various conditions and dictate when you want to display your widgets.

Related content

  • WooCommerce: Add Second Description @ Product Category Pages
    In terms of SEO, if you’re trying to rank your product category pages, you really need to make the most of the default WooCommerce product category “description” and “thumbnail”. Most themes, if compatible with WooCommerce, will show this content right below the product category name and above products. Nothing new so far. But what if […]
  • WooCommerce Conditional Logic – Tags, Examples & PHP
    The WooCommerce and WordPress conditional tags (“WooCommerce and WordPress Conditional Logic”) can be used in your functions.php to display content based on certain conditions. For example, you could display different content for different categories within a single PHP function.
  • WooCommerce: Show Message Upon Country Selection @ Checkout
    If you have country-specific shipping conditions, or you want to show a message conditionally after country selection on the checkout page, here’s a simple WooCommerce PHP snippet you can freely use. This can be slightly customized to target state selection instead. I’ve also edited the initial code to make this work on load as well, […]
  • WooCommerce: Show Category For Each Product @ Shop Page
    A client of mine has a category called “Brand”. Each product is assigned to a specific Brand subcategory e.g. Nike, Adidas, etc. The goal of this task was to show the “Brand” subcategories in the shop/category/loop pages as a way to help the user identify the brand name. The same can be applied to showing […]
  • WooCommerce: Per-Product Terms & Conditions @ Checkout
    A freelance client sells two distinct products on the same website: a membership and an online course. Two different audiences, different formats and… different Terms & Conditions. The goal was therefore to display the “Terms & Conditions” checkbox on the Checkout page based on the product in the cart. Once again, we’re going to use […]

Rodolfo Melogli

Business Bloomer Founder

Author, WooCommerce expert and WordCamp speaker, Rodolfo has worked as an independent WooCommerce freelancer since 2011. His goal is to help entrepreneurs and developers overcome their WooCommerce nightmares. Rodolfo loves travelling, chasing tennis & soccer balls and, of course, wood fired oven pizza. Follow @rmelogli

8 thoughts on “WooCommerce: Display Different Widgets Based On Product Category

  1. Do you think this plugin is still safe to use? I see that it’s very lightweight, with only one file – and it does exactly what I am looking for to add a product filter to my woocommerce store for some of the product categories.

    The alternatives are all very big plugins offering 95% functionality I don’t need.

    What do you think? Would you still use it today, or do you know of any good alternatives?

    1. Yes, still good! I guess for those who are still on Classic Editor this is perfectly fine. Not sure if it’s compatible with Gutenberg.

  2. Hi.
    Looks like Widget Logic doesn’t work on Widget blocks.

    1. I’m sure they’re working on it, it’s a very popular plugin. For now, I’ve been using “Classic Widget” plugin honestly because I don’t like the new UX at all

  3. Hi, is there a way to write this piece of code on functions? so that no need to install a plugin?

    1. Hi Milad, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!

  4. Hi
    Widget Logic has not been updated in two years, there is no support.

    1. Thanks for your feedback!

Leave a Reply

Your email address will not be published. Required fields are marked *