Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clarify register_nav_menus #451

Open
woodz- opened this issue Nov 14, 2019 · 4 comments
Open

clarify register_nav_menus #451

woodz- opened this issue Nov 14, 2019 · 4 comments

Comments

@woodz-
Copy link

woodz- commented Nov 14, 2019

I feel the meaning of the array arguments of the register_nav_menus() function is not really clear (maybe for newcomers only). Furthermore how the dict key 'primary' fits to wp_nav_menu()'s 'theme_location' is not clear.

Why I am stating this is, because in my case I already have a working menu defined in wp-admin. Its name is 'Mainmenu'. And I want to apply it for the nav_walker instead of using it in a previous fusion based theme.

If I put this name into register_nav_menus() array instead of 'Primary Menu', it won't take effect. Even if I create a new menu in wp-admin with the name 'Primary Menu', it won't show up.

The only thing that worked for me was to leave the value of key 'primary' empty in wp_nav_menu function. Thus I feel I canceled out the concept of 'primary' completely as any change of the parameters of register_nav_menus() won't have any more consequence.

The statement

Displaying the Menu
To display the menu you must associate your menu with your theme location. You can do this by selecting your theme location in the Theme Locations list while editing a menu in the WordPress menu manager.

makes the situation more confusingly, since it is not clear what

associate your menu

mean. By its name? By its option under "Menu Settings" of the wp-admin? By Theme Location under "Manage Locations" of the wp-admin? ...

Also, some identifiers seem to have changed with newer wordpress versions like "Main Navigation" in wp-admin.

Would it be possible to expand the instructions by concrete samples where one can see which values are gonna be replaced? Plus mention the version of wordpress, which had been the base by the time of writing the instructions.

@pattonwebz
Copy link
Member

Hey there, thanks for flagging this as not easy to understand. The instructors could be expanded and clarified a bit but I am not great at writing documentation like this. Would you consider making a PR with your suggested changes and I'll merge those in?

@woodz-
Copy link
Author

woodz- commented Nov 15, 2019

@pattonwebz, sure I could do that. If we could have a living conversation here, wehre I will ask you about concrete details for parameterization of the function in your templates would obviously ease the task.

@pattonwebz
Copy link
Member

Of course we can have a conversation and I can answer the questions, I did not mean it to look like I was about to skip over them and never come back lol

I planned to cycle back here tomorrow and answer them once I'm at my desk. It's already late for me and it's hard to scroll back and forth answering on mobile.

We can catch up tomorrow about it and thank you for helping to improve and make things more understandable. It will ease a lot of people's getting started worries or confusions the docs create :)

@IanDelMar
Copy link
Collaborator

@woodz- , you need to put the "id" of the theme_location in there. Somewhere in your theme there is something like

function prefix_register_nav_menu(){
        register_nav_menus( array(
            'id_theme_location_1' => __( 'Name theme location 1', 'text_domain' ),
            'id_theme_location_2'  => __( 'Name theme location 1', 'text_domain' ),
        ) );
}

If you created a menu and assigned it to, e.g., 'Name theme location 1', then you have to use 'id_theme_location_1' in your wp_nav_menu(). As the menues registered depend on your theme and not your WordPress version - unless you use its default theme -, it should be totally independent of whether WordPress names something "Main Navigation" or "It's the end of the world".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants