Different Main Navigation per category

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!

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)