S
S
Stanislav2018-11-16 10:51:26
WordPress
Stanislav, 2018-11-16 10:51:26

How to determine that we are currently displaying the "default category"?

There is WP, WC is installed on it, and of course there is a product category marked as the default category. How do we determine when displaying the `archive-product.php` template that we are currently going to display this particular category? This is necessary in order not to print certain text in the default category, which is printed in all other categories.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alex Vasilyev, 2018-11-16
@lamo4ok

The default category is stored in the "default_product_cat" option. Here is an example of how you can use validation

$default_category_id = get_option( 'default_product_cat', 0 );

if ( is_tax( 'product_cat', $default_category_id ) ) {
  echo 'Default Category!';
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question