I am trying to create a custom way to order my new custom post type.

Here is what I am envisioning:

  • There would be a custom way to order posts in an entirely unique order for display (Number, automatic value, etc.) This would be so I could avoid needing to manually change a ton of publication dates on posts to get the right order.
  • If there was no number/automatic value/etc. entered then it would display based on when it was published at the end of the list.

I am using CMB2 for the meta-data fields on my custom post type.

Does anyone have any suggestions or ideas? I realize that this is a complicated problem, but I want to be able to order posts in a custom order that is not by author, date published, or title.

2 Answers 2


With register_post_type(), you can specify the 'page-attributes' => true property, and you'll get the "menu order" metabox which you see on pages. With this you can custom order your items, where the default is always 0, which means they will always show, even if you don't set a value.

You don't actually have to set the page-attributes attribute to use the the menu_order post property/column. You can set that value programmatically. To query with the custom ordering in place, you can use the menu_order property in your WP_Query args: https://developer.wordpress.org/reference/classes/wp_query/#order-orderby-parameters

  • In Wordpress 6.2.2, I needed to add this to the supports options, e.g. 'supports' => array('title', 'editor', 'page-attributes'),. Simple setting a page-attributes option seemed to have no effect. Commented Jun 14, 2023 at 16:45

You could just add a 'priority' or 'order' custom field (number) to your post type and order based on that.

See Custom query with orderby meta_value of custom field, wp_query / #order-orderby-parameters

  • Yes. I had thought of this, but the problem I run into is if there is no number/priority in the meta-data box, then it will not be displayed. This could be a problem for clients that use this feature that don't know what they should be looking for.
    – Michael
    Commented Aug 25, 2019 at 22:42
  • I'm not familiar with CMB2, can't you just set a default value (either 0, or a maximum, say 999)? Also, I would've thought even without a value, you use the meta_key just for orderby so posts without ranking should still be displayed - just at the end?
    – pax
    Commented Aug 27, 2019 at 5:10

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.