4

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

2
  • Where exactly is that register_nav_menus code placed? Commented Jul 10, 2018 at 8:48
  • Updated the post
    – SamXronn
    Commented Jul 10, 2018 at 8:55

1 Answer 1

5

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 ;)

2
  • Urgh, thanks can't believe I didn't see this, thanks!
    – SamXronn
    Commented Jul 10, 2018 at 9:09
  • It took me a longer while to notice that :) Commented Jul 10, 2018 at 9:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.