Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am using the Woocommerce plugin. I am trying to create a different container for when I am displaying multiple products then when I display multiple categories.

So far in my archive_products I have a check for is_shop() and if it is then it means that I am displaying categories and not products. So I load my category style containers.

The problem is that if the category has sub categories and you click to see those sub categories, you are now failing the is_shop() function.

How can I still know if I am up to displaying available products or if I am displaying subcategores?

share|improve this question
add comment

1 Answer

I think the conditional you're looking for is:

is_product_category() Returns true when viewing a product category archive.

You can see the docs at Conditional Tags

A bit of Google searching seems to indicate that this isn't always reliable, depending upon your scenario. See here on WordPress codex.

share|improve this answer
    
is_product_category() is for displaying products of a particular category. I am looking for displaying more sub-categories. –  Lucky Luke Jan 24 '13 at 21:19
    
A subcategory is still a category, so I would think is_product_category() would still apply. –  helgatheviking Jan 24 '13 at 21:22
    
@helgatheviking but since i dont display products when displaying sub categories I want to know if this a product page. –  Lucky Luke Jan 25 '13 at 11:24
    
@LuckyLuke then the conditional would be is_product(), about five lines down in the documentation link I placed in the answer. –  Stephen Jan 25 '13 at 13:20
    
@Stephen that would only return true when on a single product page, not when displaying multiple products –  Lucky Luke Jan 26 '13 at 17:48
show 1 more comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.