wp_nav_menu return me menu list in ascending order how can i arrange menu as same as dashboard menu

by dev_ramiz_1707   Last Updated August 01, 2018 07:08 AM

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

this is simple wp_nav_menu

enter image description here

you can see ascending order from above example

i have done in WP

enter image description here

wp_nav_menu give me ascending order menu how can i arrange as dashboard.

please help.



Answers 1


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,

              )
          );       
Trilok
Trilok
August 01, 2018 06:51 AM

Related Questions


How to open a link in other column when clicked

Updated July 17, 2017 19:08 PM


On screen music/audio player that grabs track URL

Updated November 12, 2016 08:03 AM

Ajax request with jQuery without WP_ajax

Updated April 25, 2018 13:08 PM