wp-bootstrap / wp-bootstrap-navwalker

A custom WordPress nav walker class to fully implement the Twitter Bootstrap 4.0+ navigation style (v3-branch available for Bootstrap 3) in a custom theme using the WordPress built in menu manager.
https://wp-bootstrap.github.io/wp-bootstrap-navwalker/
GNU General Public License v3.0
3.37k stars 1.94k forks source link

clarify register_nav_menus #451

Open woodz- opened 5 years ago

woodz- commented 5 years ago

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 commented 5 years ago

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- commented 5 years ago

@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 commented 5 years ago

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 commented 5 years ago

@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".