1
 <?php
              wp_nav_menu(array(
                  'theme_location' => 'primary',
                  'container' => 'ul',
                  'menu_class'=> 'top-menu'
                  /* 'walker' => new Walker_nav_Primary() */
                  )
              );                  
          ?>

This is a simple wp_nav_menu

enter image description here

You can see ascending order from above example

I have done this in WP.

enter image description here

wp_nav_menu gives me ascending order menu. How can I arrange as dashboard?

Please help.

  • What theme are you using? Can you double check you have a theme location called 'primary'. This could depend on the theme being used. It would be set using "register_nav_menus" possibly in the theme's functions.php file. If there is no location called 'primary' you would just need to set it to the correct name. – junkrig Aug 1 '18 at 7:08
  • yes, you can see below primary menu has right sign – user147874 Aug 1 '18 at 7:13
  • Is the menu actually in this reverse order if you inspect the page's HTML ? wp_nav_menu() is supposed to output the menu in the same order as it is set in the back-end as you would expect ; so I suspect the order is only reversed with CSS on your front-end. – Iceable Aug 1 '18 at 7:59
  • no its not dude. not in reverse order. – user147874 Aug 1 '18 at 8:13
0

Please use below code in your theme funcation.php file

function my_asc_nav_menu($menu, $args) {
if (isset($args->reverse) && $args->reverse) {
return array_reverse($menu);
}
return $menu;
}
add_filter('wp_nav_menu_objects', 'my_asc_nav_menu', 10, 2);

And also use your wp_nav_menu function as below:

 wp_nav_menu(array(
              'theme_location' => 'primary',
              'container' => 'ul',
              'menu_class'=> 'top-menu',
              'reverse' => FALSE,

              )
          );       
|improve this answer|||||
  • i don't want to this like reverse or with sorting i need as same as dashboard order. – user147874 Aug 1 '18 at 6:58
  • Ok then please double check have you install any plugin or implemented the hook related to the menu because WordPress default functionality is that menu display same order as dashboard – Trilok Aug 1 '18 at 7:27
0

As far as I can tell, if the theme_location is incorrect, the menu defaults to alphabetical order, rather than the order set on your menu screen.

I can see you have a tick next to Primary Menu in the menu settings, but the actual key / slug might be different in your theme. For example:

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

If you do a search for:

register_nav_menus

in the code of your theme, 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',
|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy