Changing the Column Order in the Admin Table CPT

Changing orders of the columns in Admin Table

Change the order of the fields in a column in a CPT (maybe I never actually did that :wink:) but I did find a time when I wanted to change the order of the columns themselves, so I would imagine you could use the same filter. Here is the code I used for changing the column order.

add_filter('manage_press_posts_columns', 'order_book_column');
function order_book_column($columns) {
  $new = array();
  foreach($columns as $key => $title) {
    if ($key=='date') // Put the Thumbnail column before the Author column
      $new['book'] = 'Associated Book(s)';
    $new[$key] = $title;
  }
  return $new;
}

Note: This needs to be rewritten and reviewed because it’s filled with “I” statements and we have no idea who submitted it.

Questions