WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am using this function

$args = array (
   'order' => 'DESC',

$items = wp_get_nav_menu_items( $custom_menu, $args );

then, if I change args to

$args = array (
   'order' => 'ASC',

and the result is still the same.

Anybody have suggestion?

share|improve this question
maybe 'order_by' => 'menu_order' parameter triggers conflict – JMau Jun 21 '13 at 8:58
@TweetPressFr: 'orderby'=>'menu_order' is default value for this param (codex.wordpress.org/Function_Reference/…) – Krzysiek Dróżdż Jun 21 '13 at 9:16
and so? I already know what you're saying and I was implying it could trigger conflicts – JMau Jun 21 '13 at 9:21

When you look in WordPress source code, you will find reason for that. On line 538 of nav-menu.php you'll find:

if ( ARRAY_A == $args['output'] ) {
    $GLOBALS['_menu_item_sort_prop'] = $args['output_key'];
        usort($items, '_sort_nav_menu_items');
        $i = 1;
        foreach( $items as $k => $item ) {
            $items[$k]->$args['output_key'] = $i++;

I didn't check why, but it looks like this sorting doesn't work right. The easiest thing you can do to fixthis is to change output type to disable this sorting.

So when you add 'output'=>OBJECT or 'output'=>ARRAY_N to your args it should work just fine.

PS. It's even known bug: http://core.trac.wordpress.org/ticket/15533

share|improve this answer
I've added 'output' => OBJECT to the args but nothing happens – Marián Zeke Šedaj Jun 21 '13 at 10:47
So you have $args = array('order'=>'DESC', 'output'=>OBJECT); now? Items should be sorted correctly with this change. You can also try 'output'=>ARRAY_N. – Krzysiek Dróżdż Jun 21 '13 at 11:57
Works for me. Here is my code. wordpress.stackexchange.com/questions/159089/… Didnt find this one before posting – thegreyspot Aug 28 '14 at 2:13

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.