How can I show different menu for different pages?

You can try it this way. Now we are talking about pages you can set up a separate template for the page that needs a different menu. This where WordPress’s newer menu feature is really nice. First if you are using the newer menu feature of WordPress place this in place of your current menu: … Read more

How is custom menu hierarchy output handled?

Each nav menu item is stored a post type named nav_menu_item. The horizontal position is stored in the column menu_order The vertical position (hierarchy) is stored as post meta field named _menu_item_menu_item_parent holding the parent nav_menu_item ID. To create nested lists WordPress looks for _menu_item_menu_item_parent on each item, and if there is an item with … Read more

wp_nav_menu() loses ‘current-menu-*’ classes on single product page within category

Looking for a solution for the same problem, I came across this: add_filter( ‘nav_menu_css_class’, ‘add_parent_url_menu_class’, 10, 2 ); function add_parent_url_menu_class( $classes = array(), $item = false ) { // Get current URL $current_url = current_url(); // Get homepage URL $homepage_url = trailingslashit( get_bloginfo( ‘url’ ) ); // Exclude 404 and homepage if( is_404() or $item->url … Read more

Overriding wp_nav_menu default arguments

If you want the options to be extensible by developers, just add a custom filter to the output: wp_nav_menu( apply_filters( ‘wpse119371_nav_menu_args’, array( ‘theme_location’ => ‘primary’, ‘container’ => false, // etc. ) ) ); Then, a developer merely has to add a filter callback: function wpse119371_filter_nav_menu_args( $args ) { // Modify $args $args[‘container’] => ‘div’; // … Read more

Menu is not visible in appearance

I have done a complete answer on this a while ago on SO. You can see the complete post here. For the sake of WPSE users, I have copied my answer from that post. I have not edited it, this post was originally about adding and displaying a nav menu to the footer, but the … Read more

Pass a parameter to a menu walker

As @toscho said, you can call the walker class with parameters as you did: new BEMwalker( ‘mobile’ ) The constructor of BEMwalker will take the arguments (like any other function or method in PHP) so you can access the parameter(s) via $this: class BEMwalker extends Walker_Nav_Menu { private $classes; public function __construct( $classes=”” ) { … Read more

Using string instead of object class instantiation on the walker argument breaks wp_nav_menu

Apparently custom nav menu walkers are not supported though they were supposed to be. I’m surprised this only has been discovered now. However, there is an easy fix for you to get them to work. Just add this to your theme: add_filter( ‘wp_nav_menu_args’, function( $args ) { if ( isset( $args[‘walker’] ) && is_string( $args[‘walker’] … Read more

What does a walker menu mean?

Walker_Nav_Menu is the core class to handle navigation menus. You can use it to handle your navigation menu, or you can create your own children class that extends this class. If you decide to use your own class, then you must pass an instance as an argument when you use wp_nav_menu() class myWalkerClass Extends \Walker_Nav_Menu … Read more