Adding ‘menu order’ column to custom post type admin screen

I want to use the menu order attribute to control ordering for a custom post type that’s going to be used for a specific purpose.

It’s easy enough to add this to the CPT via supports => array('page-attributes') but how do I expose the menu order value on the admin listing screen for this CPT?


OK – in the end turned out to be fairly simple – as I’d had some kind of mental block – menu_order is a variable in the $post object (thanks to @brady for reminding me of that).

@scribu’s post on creating sortable column values then gives the rest.

So, assuming the custom post type is called header_text, these are the functions and hooks that are needed:

Add a new column for the order

* add order column to admin listing screen for header text
function add_new_header_text_column($header_text_columns) {
  $header_text_columns['menu_order'] = "Order";
  return $header_text_columns;
add_action('manage_header_text_posts_columns', 'add_new_header_text_column');

Render the column values

* show custom order column values
function show_order_column($name){
  global $post;

  switch ($name) {
    case 'menu_order':
      $order = $post->menu_order;
      echo $order;

Set the column to be sortable

* make column sortable
function order_column_register_sortable($columns){
  $columns['menu_order'] = 'menu_order';
  return $columns;

Leave a Comment