WooCommerce is_catalog() function

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 :

  1. Shop page
  2. Product taxonomy archive page
  3. 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();
}

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Up Next:

How does URL rewriting work internally in WordPress?

How does URL rewriting work internally in WordPress?