5

Hey Guys, I'm trying to build a right aligned, wrapping capable wp_nav_menu powered menu.

Is there a way to have it rendered backwards, so that float: right; would work and not mess up the order?

I was hoping for something like this:

<?php wp_nav_menu( array('sort_order' => 'DESC' )); ?> 

Thanks!

3 Answers 3

5

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

0

You could write a custom walker for your wp_nav_menu() call. Short of that, I don't think there's anyway to do what you're trying to do.

You could pass such arguments to your fallback function (e.g. wp_list_pages() or wp_page_menu()), but the list-item order of wp_nav_menu() is entirely dependent upon the user-defined menu applied to the given menu location.

1
  • Thanks Chip! It's not often you "can't" do something in WordPress. Funny you answered this question, I just emailed you through your website about a plugin question! What a coincidence! Commented Apr 18, 2011 at 18:40
0

oops! or try like this

<?php $args = array( 'sort_column' => 'menu_order, post_title' ); ?> 

for more parameters http://codex.wordpress.org/Function_Reference/wp_page_menu

2

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.