I added 'supports' => 'page-attributes'
to my custom post type, and now i have the meta box for page ordering.
When i use the argument 'sort_column' => 'menu_order'
with get_pages()
on my custom post type, everything orders properly.
So why do the custom pages not order properly when i query the posts using query_posts(array('orderby' => 'menu_order'))
And what can i do to get them to order by the menu order?
Here is the query im using incase anyone wants to see it.
<?php
$current_term = ($wp_query->query_vars['section'] <> '') ? $wp_query->query_vars['section'] : $menu_arr[0];
query_posts(array( 'post_type' => 'module',
'orderby' => 'menu_order',
'tax_query' => array(array( 'taxonomy' => 'section',
'field' => 'slug',
'terms' => $current_term )),
'post_parent' => 0 ));
?>
3 s
I’ve just had to do the same thing as you, here is what I did to get this working:
'supports' => array('title', 'editor', 'thumbnail', 'page-attributes')
Register the post type with supports of page attributes. This adds the menu order meta box to the edit screen. From there you can place the order.
Then run my custom query:
$args = array(
'numberposts' => -1,
'orderby' => 'menu_order',
'order' => 'ASC',
'post_type' => 'staff'
);
$staff = get_posts($args);
set orderby
to menu_order and order
to ASC. Remember if you do not set a value in menu order it sets it to 0. So any posts without an order set will appear first.