I'm a backend dev learning WordPress for the first time. I'm trying to create a menu in the admin GUI, but the menu isn't displaying all of the items that it should.
As you can see, the menu is configured to display two pages and three posts.
But it actually only displays links to the two pages. The links to the three posts are missing.
The code that renders the menu is as simple as it gets.
<?php wp_nav_menu( array( 'theme_location' => 'top-menu' ) ); ?>
So is the code that registers the menu.
<?php
function register_my_menus() {
register_nav_menus(
array(
'header-menu' => __( 'Header Menu' )
)
);
}
add_action( 'init', 'register_my_menus' );
?>
Why on earth isn't this working???
I'm a backend dev learning WordPress for the first time. I'm trying to create a menu in the admin GUI, but the menu isn't displaying all of the items that it should.
As you can see, the menu is configured to display two pages and three posts.
But it actually only displays links to the two pages. The links to the three posts are missing.
The code that renders the menu is as simple as it gets.
<?php wp_nav_menu( array( 'theme_location' => 'top-menu' ) ); ?>
So is the code that registers the menu.
<?php
function register_my_menus() {
register_nav_menus(
array(
'header-menu' => __( 'Header Menu' )
)
);
}
add_action( 'init', 'register_my_menus' );
?>
Why on earth isn't this working???
Share Improve this question edited Jan 30, 2020 at 22:06 Mathew Alden asked Jan 30, 2020 at 21:44 Mathew AldenMathew Alden 1212 bronze badges1 Answer
Reset to default 2Your menu name is not consistent.
When you created the menu, you named it 'header-menu'
. But when you rendered it, you tried to render 'top-menu'
. 'top-menu'
doesn't exist; it needs to also say 'header-menu'
.