WordPress is pretty amazing. More than 33k plugins in WordPress plugin repository. There are lots of customization we could do with the hooks and APIs available for us to use. Have you ever wonder – how to move admin columns?
In this WordPress Tutorial we will go over steps on how to switch/modify WordPress Admin Console Post columns.
Let’s take a look at this default WordPress Post Column.
Let’s move Categories
column before Title
column.
Let’s take a look at below code snippet which you need to include into your WordPress Theme’s functions.php
file. manage_posts_columns
is a filter applied to the columns shown on the manage posts screen. It’s applied to posts of all types except pages.
// Move "Categories" column before "title" column function crunchify_reorder_columns($columns) { $crunchify_columns = array(); $categories = 'categories'; $title = 'title'; foreach($columns as $key => $value) { if ($key==$title){ $crunchify_columns[$categories] = $categories; } $crunchify_columns[$key] = $value; } return $crunchify_columns; } add_filter('manage_posts_columns', 'crunchify_reorder_columns');
Now let’s take a look at scenario in which you may need to move couple of more columns before title columns, i.e. Move tags
, categories
, author
column before title
column. Take a look at below image.
Please use below code to achieve the same.
function crunchify_reorder_columns($columns) { $crunchify_columns = array(); $title = 'title'; foreach($columns as $key => $value) { if ($key==$title){ $crunchify_columns['date'] = ''; // Move date column before title column $crunchify_columns['author'] = ''; // Move author column before title column $crunchify_columns['tags'] = ''; // Move tags column before title column } $crunchify_columns[$key] = $value; } return $crunchify_columns; } add_filter('manage_posts_columns', 'crunchify_reorder_columns');
Browse list of similar more than 200 WordPress Articles.