Menu Order & posts
written by: Jeff McNearMenu Order & posts
WordPress post queries by default are sorted by post date with the following alternatives
- ‘none’ – No order
- ‘ID’ – Order by post id
- ‘author’ – Order by author
- ‘title’ – Order by title (‘post_title’ is also accepted.)
- ‘name’ – Order by post name (post slug)
- ‘type’ – Order by post type
- ‘modified’ – Order by last modified date
- ‘parent’ – Order by post/page parent id
- ‘rand’ – Random order
- ‘comment_count’ – Order by number of comments
- ‘meta_value’ – Note that a ‘meta_key=keyname’ must also be present in the query
- ‘menu_order’ – Order by Page Order
see: WP_Query Arguments
Generally speaking I would say the ID, author, title, name, type & parent are not particularly valuable. Rand & comment count do have value but only in narrow use cases. Any custom field would be expressed as a meta value opening many sorting avenues…
Core WordPress has developed the menu order interface to allow the setting of menu order in individual pages, via the quick editor in the page array and even will use this value as a way to sort the items in that array – doing something like this with a custom meta value is possible but would require some work.
For some reason when you are in the editor for posts you will not see the menu order controls you see when in the page editor – indeed you may not even see a panel for post attributes at all.

However in the database each post is given a menu_order value of “0” – meaning that menu order for posts is a meaningless ordering parameter.
This article describes a process that will expose menu order controls in the post editor – using this block of code:
add_action( 'admin_init', 'posts_order_wpse_91866' );
function posts_order_wpse_91866()
{
add_post_type_support( 'post', 'page-attributes' );
}
However getting the entry to be properly recorded both via the “quick edit” function and by Gutenberg requires another block of code described in this article. Here is the block of code:
add_action(
'rest_api_init',
function() {
register_rest_field(
'post',
'menu_order',
[
'get_callback' => function($object) {
if (! isset($object['menu_order'])) {
return 0;
}
return (int) $object['menu_order'];
},
'schema' => [
'type' => 'integer',
]
]
);
}
);
With these two elements in place there is editor control over menu order for posts!
… and this technique can be applied to custom post types