public
Last active

Reverse wordpress nav menu

  • Download Gist
reverse-nav-menu.php
PHP
1 2 3 4 5 6 7 8 9 10 11 12 13
/**
* Enables a 'reverse' option for wp_nav_menu to reverse the order of menu
* items. Usage:
*
* wp_nav_menu(array('reverse' => TRUE, ...));
*/
function my_reverse_nav_menu($menu, $args) {
if (isset($args->reverse) && $args->reverse) {
return array_reverse($menu);
}
return $menu;
}
add_filter('wp_nav_menu_objects', 'my_reverse_nav_menu', 10, 2);

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.