How to check if I am displaying categories on a Woocommerce page?

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.

Read More

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?

Related posts

Leave a Reply

1 comment

  1. 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.