WooCommerce has some great conditional tags. But sometimes, you might need to run your code on all the catalog pages.
Catalog page is basically any page where WooCommerce shows products in a loop. These could be :
- Shop page
- Product taxonomy archive page
- Filtered result page
There is no such function in WooCommerce but we can easily create on like this:
When to call this function?
Just like any other template tags, you need to call this function after posts_selection
hook has been fired. A safe action would be tempate_redirect
<?php
function is_catalog() {
return is_product_taxonomy() || is_shop() || is_filtered();
}