I'm using a theme based on underscores, and I have registered my menus in the following way.
function register_my_menu() {
register_nav_menus( array(
'primary' => esc_html__( 'Primary' ),
'social_media' => esc_html__( 'Social Media' ),
) );
};
add_action( 'init', 'register_my_menu' );
When calling the menus like so:
wp_nav_menu(
['theme_location' => 'primary']
);
wp_nav_menu(
['theme_location' => 'social_media']
);
only the primary menu shows up.
I checked if themenu exists and is registered with has_nav_menu()
and it returns true
.
Here is my backend. The menu is registered and assigned to a location:
No, it's not on display none. I checked the markup, and it's empty.
I disabled JS and it's still the same. I tried adding a new menu:
…
'secondary' => esc_html__( 'Secondary' ),
…
and went through all the procedure, and when calling
wp_nav_menu(
['theme_location' => 'secondary']
);
nothing happens. Markup is still empty. Somehow it's only working with the name 'primary'
I'm using a theme based on underscores, and I have registered my menus in the following way.
function register_my_menu() {
register_nav_menus( array(
'primary' => esc_html__( 'Primary' ),
'social_media' => esc_html__( 'Social Media' ),
) );
};
add_action( 'init', 'register_my_menu' );
When calling the menus like so:
wp_nav_menu(
['theme_location' => 'primary']
);
wp_nav_menu(
['theme_location' => 'social_media']
);
only the primary menu shows up.
I checked if themenu exists and is registered with has_nav_menu()
and it returns true
.
Here is my backend. The menu is registered and assigned to a location:
No, it's not on display none. I checked the markup, and it's empty.
I disabled JS and it's still the same. I tried adding a new menu:
…
'secondary' => esc_html__( 'Secondary' ),
…
and went through all the procedure, and when calling
wp_nav_menu(
['theme_location' => 'secondary']
);
nothing happens. Markup is still empty. Somehow it's only working with the name 'primary'
1 Answer
Reset to default 1If found out that this is removing my menu:
function add_menu_icon ( $items, $args ) {
if ( $args->theme_location == 'primary' ) {
$elements = '<li class="custom-logo">'
. get_custom_logo() .
'</li>';
$elements .= $items;
$items = $elements;
return $items;
}
}
add_filter( 'wp_nav_menu_items', 'add_menu_icon', 10, 2 );
I still haven't figured out why.
secondary
menu? – Nilambar Sharma Commented May 13, 2019 at 8:19