Question about WooCommerce sidebar widget
-
Hi,
We are using the WooCommerce sidebar widget.
In that widget I have placed three custom made buttons.
So these buttons now show up on all the product pages, no matter what the product category is.My question is: is it possible to show different content in the widget, depending on the category of the product that is currently viewed?
-
Thanks Mike, it looks like the thing I need.
I took a look at the list of possible codes, but I don’t see anything that includes WooCommerce. How can I ‘call’ the widget to appear only on a product page that’s within a certain product category of WooCommerce?Thanks Mike! That was a good website.
I think I found the code I need:
is_product_category( array( 'cursussen', 'reizen' ) )
But now the widget isn’t showing at all on any page.
How can I figure out if my theme is interfering?Does just
is_product_category()work?no 🙁
I guess the question is then, are you using it on a category page. Where is this happening?
For example on this page:
http://bit.ly/1U2Od2mIn the right sidebar there’s two widgets now.
There should be a third one with three buttons in it.
At that widget I added the logic
is_product_category()
The category of this product is ‘Reizen’This is a product, not a category.
Correct, it is a product page, but the product is in a certain product-category.
We have three categories and that one widget should only be visible on the productpages of the products in two of those three categories.It’s in the category, but its not is_product_category. Use the has_term function.
Thank you Mike.
I’ve tried
has_term( 'reis')
because ‘reis’ is in the tags.
I’ve also tried
has_term( 'reizen')andhas_term( 'Reizen')
because that’s the name of the productcategory (didn’t know if it was case sensitive, so I tried both), but unfortunately, neither of those is working.
I had a look at the website you gave me and I also tried has_tag, and in_category but neither of those worked either.Can you help me out?
I’d really like this to work, cause it sounds just like the thing I need.taxonomy is required.
So it would be:
has_term( 'reis', 'product_cat' )reis would be the slug.
I’m sorry, it didn’t work.
I tried
has_term( 'reis', 'product_cat' )
has_term( 'Reizen', 'product_cat' )
has_term( 'reizen', 'product_cat' )but neither did the trick.
Just to be clear, when you edit a category, is the slug reizen or something else? Not the name,
The topic ‘Question about WooCommerce sidebar widget’ is closed to new replies.