30

I have a special case where I'd like to order posts in a custom order and it would be great to use the "menu_order" field that is normally only used for pages. What would be the best way to expose that in the WordPress admin UI?

1 Answer 1

48

Apparently it's as easy as:

add_action( 'admin_init', 'posts_order_wpse_91866' );

function posts_order_wpse_91866() 
{
    add_post_type_support( 'post', 'page-attributes' );
}

And then doing the query:

$order_posts = new WP_Query(array(
    'post_type' => 'post', 
    'post_status' => 'publish', 
    'orderby' => 'menu_order', 
    'order' => 'ASC', 
) );
3
  • Glad I asked. I was thinking I'd need to add a custom meta box and just save to the posts table manually.
    – tooshel
    Commented Mar 25, 2013 at 16:57
  • Apparently, this doesn't work with Gutenberg. Here is an updated version that works: gist.github.com/chrisguitarguy/1301501
    – thebigtine
    Commented Mar 6, 2019 at 0:17
  • hooking into "admin_init" worked for me Commented Jul 5, 2019 at 6:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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