0

I am currently working on my own theme. In this theme I want two menus topmenu and bottommenu.

In the functions.php file I have the following code:

// This adds the support to add a thumbnail and custom menus
function thumbnail_menu_support() {
    add_theme_support( 'post-thumbnails' );
    register_nav_menus(
        array(
            'topmenu' => __( 'Top menu' ),
            'bottommenu' => __( 'Bottom menu' )
        )
    );
}
add_action( 'init', 'thumbnail_menu_support' );

In my header.php and in the footer.php I have the following code:

<?php wp_nav_menu( array(
    'menu'              => 'Top menu',
    'menu_id'           => 'topmenu',
    'container'         => false,
    'fallback_cb'       => false,
    'theme-location'    => 'topmenu'
) ); ?>

and

wp_nav_menu( array(
    'menu'              => 'Bottom menu',
    'menu_id'           => 'bottommenu',
    'container'         => false,
    'fallback_cb'       => false,
    'theme-location'    => 'bottommenu'
) );

Now, when I make a menu in the backend of Wordpress, and specify that it should only be in the top menu, it will be rendered in both menus.

See this: enter image description here

1 Answer 1

0

I actually found the answer on stackexchange as well: https://wordpress.stackexchange.com/a/184149/132736

I need to replace the 'theme-location' by 'theme_location'. I simply misread the function reference on the WordPress codex.

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.