Edit, complete function –

function themename_setup() {
    // WordPress Menu Locations
    register_nav_menus(array(
        'primary' => esc_html__( 'Primary', 'themename' ),
        'footer ' => esc_html__( 'Footer', 'themename' ),
    ));
}
add_action( 'after_setup_theme', themename_setup' );

The primary menu works exactly as expected

I’ve set up a foot menu location in my functions.php file;

register_nav_menus(array(
    'primary' => esc_html__( 'Primary', 'themename' ),
    'footer ' => esc_html__( 'Footer', 'themename' ),
));

In the admin, I’ve created a new menu and assigned it to this new location.

However, when I output this menu the menu items retrieved are all of the pages from the admin.

<?php wp_nav_menu(array('theme_location' => 'footer')); ?>

I only want the pages that have been assigned to this menu

1 Answer
1

It’s pretty easy then… And it works exactly how it should…

You register menu 'footer ' – there’s a space at the end (so you have two locations defined 'primary' and 'footer ').

And then you use it as 'footer' – without that space. There is no such location defined anywhere 😉

Leave a Reply

Your email address will not be published. Required fields are marked *