wp_nav_menu sort order?

I just found this handy little function that ads the ability to reverse the menu output order. it might come in handy:

/**
* 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);

All you need to do is ad 'reverse' => true as one of the wp_nav_menu parameters. 🙂

this is the source: https://gist.github.com/1291914

Leave a Comment