Answer the question
In order to leave comments, you need to log in
Display menu for individual categories, wordpress?
Hello!
There are two categories of products, on separate pages, please tell me how to display different side menus on these pages?
I hope for help)
I will be grateful!
Answer the question
In order to leave comments, you need to log in
use the is_category() conditional tag - unless, of course, standard categories are enabled for products.
example:
<?php
if(is_category(5)){ // 5 = id категории
// вывод меню
}
?>
In your case, you need a combination of is_tax (for product listing) and has_term (for product page)
That is, it will look like this:
if ( is_tax( $taxonomy, $term1 ) || has_term( $term1, $taxonomy ) ) {
dynamic_sidebar( 'sidebar1' );
} elseif ( is_tax( $taxonomy, $term2 ) || has_term( $term2, $taxonomy ) ) {
dynamic_sidebar( 'sidebar2' );
} else {
dynamic_sidebar( 'sidebar3' );
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question