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.

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.

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!

Questions? Feedback? Support? Leave your Comment Now!

If you are writing code, please wrap it between shortcodes: [php]code_here[/php]. Failure to complying with this (as well as going off topic, not writing in English, etc.) will result in comment deletion. You should expect a reply in about 2 weeks - this is a popular blog but I need to get paid work done first. Please consider joining BloomerArmada to get blog comment reply priority, ask me 1-to-1 WooCommerce questions and enjoy many more perks. Thank you :)

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