Support » Fixing WordPress » get_posts not using orderby=menu_order

  • Hi there, based on the get_posts documenation I should be able to use any column in the wp_posts table to sort entries. However, when I use menu_order (which has values in the table) it is not changing the sort order.

    Is this the correct usage?
    $myposts = get_posts(‘post_type=page&post_parent=80&orderby=menu_order&numberposts=’);

Viewing 6 replies - 1 through 6 (of 6 total)
  • To be honest, I do’t see anything on that page mentioning “menu_order”.
    Only Pages have menu order, btw.

    Nothing on that page specifically says that, but there is a line that says “Note: The $orderby value can be the name of any field in the wp_posts table.”

    And menu_order is a column in the wp_posts table.

    see the history:
    and Schulte’s notes on July 12, 2005. Keyword: “assume”.

    Since there is no possibility to define anything as “menu_order” for the posts (as you have in the Write Page subpanel), I think, no, I assume it does’nt really work for posts 🙂

    Actually, I am using get_posts to get pages (post_type=page). So you would assume it would work. But we all know what assuming can do. 🙂

    I guess this should be filed as a bug then, or the codex updated? Or is there another way that I should be getting pages in this manner?



    Ah, I was able to resolve this by using get_pages and sort_column as one of the params.

    For more info.

    WP 2.7, wp-includes/query.php at line 2041 seems like not having code for case “menu_order”


    case 'menu_order':


    case 'menu_order':
      $orderby = "$wpdb->posts.menu_order";

    and it will work. Write this change down somwhere 🙂
    Strange it’s not implemented.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘get_posts not using orderby=menu_order’ is closed to new replies.