WordPress.org

Ready to get started?Download WordPress

Forums

wp_nav_menu : theme_location vs. menu parameters (3 posts)

  1. bbross
    Member
    Posted 1 year ago #

    Hi everyone.

    Quick question about the behavior of the wp_nav_menu function. The codex says :

    Given a theme_location parameter, the function displays the menu assigned to that location, or nothing if no such location exists or no menu is assigned to it.

    If not given a theme_location parameter, the function displays

    * the menu matching the ID, slug, or name given by the menu parameter, if that menu has at least 1 item;
    * etc.

    In my experiments however, "menu" seems to be taking precedence over "theme_location" if both are declared. The following code outputs the "Primary Navigation" menu as defined via the admin panel, not the menu actually associated with the registered "footer_menu" location in said panel.

    wp_nav_menu( array(
    	'menu' => 'primary-navigation',
    	'theme_location' => 'footer_menu',
    	'fallback_cb' => ''
    ) );

    This seems inconsistent with the doc.

    I know it's not a big deal, but am I missing something ?

    Thanks in advance for your help !

  2. Rajesh Soni
    Member
    Posted 1 year ago #

    If not given a theme_location parameter

    If you specify a theme_location parameter, it simply overrides the menu parameter ?!

  3. bbross
    Member
    Posted 1 year ago #

    Thanks for your reply.

    As a matter of fact, it doesn't seem to do so. On the contrary : the "menu" parameter seems to override the "theme_location" parameter when both are declared. See my example above.

    Am I not seeing the elephant in the room or is there indeed some inconsistency in the Codex ?

Topic Closed

This topic has been closed to new replies.

About this Topic