J
J
Junior2015-09-30 11:00:55
JavaScript
Junior, 2015-09-30 11:00:55

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

3 answer(s)
M
Maxim E, 2015-09-30
@creativeworm

use the is_category() conditional tag - unless, of course, standard categories are enabled for products.
example:

<?php 
if(is_category(5)){ // 5 = id категории
// вывод меню
}
?>

D
Dmitry Korolev, 2015-09-30
@Apathetic

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' );
}

W
Wheelie, 2015-09-30
@Wheelie

maybe something like that.

<?php
$a = the_category_ID();
if ($a == 1) {
//меню
}
?>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question