X

Change wordpress admin post columns order

I have needed to move a post column like "date, tags, author" or even a custom column within the wordpress admin. This is a simple method that I used to change the order of columns within the admin. What you have is two variables you will need to change $move and $before. Move is the name of the column you would like to move. Before is the name of the column you would like to move it before. The following snippet will let you move the author column before the post title column.


add_filter('manage_posts_columns', 'column_order');
function column_order($columns) {
  $n_columns = array();
  $move = 'author'; // what to move
  $before = 'title'; // move before this
  foreach($columns as $key => $value) {
    if ($key==$before){
      $n_columns[$move] = $move;
    }
      $n_columns[$key] = $value;
  }
  return $n_columns;
}

If you want to move multiple columns you will need to do things in another way as the above code was just to make things as simple as possible. The next snippet will move both the date and author columns before the post title column.

add_filter('manage_posts_columns', 'column_order');
function column_order($columns) {
  $n_columns = array();
  $before = 'title'; // move before this

  foreach($columns as $key => $value) {
    if ($key==$before){
      $n_columns['date'] = '';
      $n_columns['author'] = '';
    }
      $n_columns[$key] = $value;
  }
  return $n_columns;
}

Comments  Leave a Reply

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our privacy policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

WordPress Launch Checklist

The Ultimate WordPress Launch Checklist

We've compiled all the essential checklist items for your next WordPress website launch into one handy ebook.
Yes, Send Me the Free eBook!