Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have a client who has the categories listed in the right-hand sidebar. He came to me today requesting a different "navigation" in the header for each category.

So basically, if you click on Category 1, the navigation changes to a set of pages (that he has set) and so on.

Is this even possible? I already have the built in menu feature activated, but I am really at a loss for this one.

share|improve this question
add comment

2 Answers

up vote 1 down vote accepted

You could set this in your theme using conditionals. Create a separate menu for each category using the WordPress menu feature (Appearances > Menus). Then in your theme, where you want the menu to display, determine which menu to display using the is_category('category-slug') and/or in_category('category-slug') conditionals and the wp_nav_menu function (http://codex.wordpress.org/Function_Reference/wp_nav_menu).

For instance:

<?php
if(is_category('first-category') || in_category('first-category)) { 
     wp_nav_menu( array('menu' => 'First Category Nav' )); 
} else {
     wp_nav_menu( array('menu' => 'Default Nav' ));
}
?>

That said, from a user-experience standpoint I'd recommend against switching out the main menu on a section-by-section basis. That will be very confusing for visitors. I'd recommend an additional category-specific menu instead, with consistent main navigation.

Hope this helps!

share|improve this answer
add comment

wp_nav-menu() allows you to call menus in different ways, by slug for example.

Just create multiple menu and add conditional logic so one of alternate menus is called if on category page.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.