[Bones] Different navigation menu on certain categoy/post
-
Hi,
I’d like to display different main navigation menu on certain categories/posts. Went through this topic:
/support/topic/custom-menus-on-different-pages
I get the idea, and it is very end-user friendly. I’m implementing it through Advanced Custom Fields by using a checkbox:
[*]Do you want the alternative menu?
If checked, the field MenuType gets a value of alt_main_nav.
I’ve registered a new menu location, alt_main_nav.
I’m using Bones, so my main nav functions is:function bones_main_nav() { wp_nav_menu( array( 'menu' => 'main_nav', /* menu name */ 'menu_class' => 'nav', 'theme_location' => 'main_nav', /* where in the theme it's assigned */ 'container' => 'false', /* container class */ 'fallback_cb' => 'bones_main_nav_fallback', /* menu fallback */ 'depth' => '3', /* suppress lower levels for now */ 'walker' => new Bootstrap_Walker() ) ); }
In my header.php I got:
<div class="nav-collapse"> <?php bones_main_nav ( wp_nav_menu( array( 'menu' => get_field('MenuType'), 'menu_class' => 'nav', 'theme_location' => 'main_nav', /* where in the theme it's assigned */ 'container' => 'false', /* container class */ 'fallback_cb' => 'bones_main_nav_fallback', /* menu fallback */ 'depth' => '3', /* suppress lower levels for now */ 'walker' => new Bootstrap_Walker() ) ) ); // Adjust using Menus in WordPress Admin ?> </div>
And the result is that I get the nav menu twice:
main_nav
main_nav
on “normal” pages/categories/posts and only main_nav should be visible and
alt_main_nav
main_nav
on posts where the custom field is set and only alt_main_nav should be visible.I’m a total newbie on PHP so I believe I’m not replacing the ‘menu’ correctly in the function above.
Please advice,
Thanks!
- The topic ‘[Bones] Different navigation menu on certain categoy/post’ is closed to new replies.