php – wp_nav_menu Returns the menu list in ascending order. How can I arrange menus similar to dashboard menus

As far as I can tell, if theme_location is false, the menu defaults to alphabetical order instead of the order you set on your menu screen.

I can see that you have a tick next to the primary menu in the menu settings, but the actual key/slug may differ in your theme. For example:

register_nav_menus( array(
    'customkey' => __( 'Primary Menu', 'twentysixteen' ),
    'social'  => __( 'Social Links Menu', 'twentysixteen' ),
) );

If you search for:

register_nav_menus

In your theme’s code, you should be able to find the correct value.

You can then add this to your code, for example:

wp_nav_menu(array(
              'theme_location' => 'customkey',

Leave a Comment