Are you looking for a way to change the order of columns within the admin? While there’s probably a plugin for this, we have created a quick code snippet that you can use to change WordPress admin post column order.
What you have is two variables, you’ll 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.
Instructions:
All you have to do is add this code to your theme’s functions.php file or in a site-specific plugin:
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; }
Note: If this is your first time adding code snippets in WordPress, then please refer to our guide on how to properly add code snippets in WordPress, so you don’t accidentally break your site.
If you liked this code snippet, please consider checking out our other articles on the site like: 43 best photography themes for WordPress and how to create a WordPress donation form.
To shift Yoast SEO title after Title, I use below code
add_filter(‘manage_posts_columns’, ‘column_order’);
function column_order($columns) {
$n_columns = array();
$move = ‘wpseo-title’; // what to move
$before = ‘author’; // move before this
foreach($columns as $key => $value) {
if ($key==$before){
$n_columns[$move] = $move;
}
$n_columns[$key] = $value;
}
return $n_columns;
}
I found it easier just to unset an element and then set it again for moving default columns.
unset($columns[‘date’]);
$columns[‘custom_email’] = ‘Email’;
$columns[‘date’] = ‘Date’;
return $columns;
Is there any way to do this for the “users” screen as well?
Hi Ben,
Your comment is a bit old, but I landed on this page because of it. I was trying to find a way to sort the user columns as well. This code works- just change manage_posts_columns to manage_users_columns in the first line