How to Add or Remove Custom Column in WordPress Post or Page

By default in WordPress post or page list there are about 5 or 6 columns you can see, which are perfect for most of the users. But sometimes you might want to add some extra column like how many times the post was vied or the thumbnail image associated with the post etc. Or you might want to remove some columns like comments or author etc. Yes you can easily add or remove custom column in WordPress post or page by adding some simple funtion. Let’s see how we can do it.

We are going to add a new column Thumbnails and remove existing column Author and Comments. Just add the following code onto your theme’s function file:

[html]
function my_pages_columns( $columns ) {

/** Add a Thumbnail Column **/
$myCustomColumns = array(
‘thumbnail’ => __( ‘Thumbnail’, ‘Theme-Text_Domain’ )
);
$columns = array_merge( $columns, $myCustomColumns );

/** Remove a Author, Comments Columns **/
unset(
$columns[‘author’],
$columns[‘comments’]
);

return $columns;
}
add_filter( ‘manage_posts_columns’, ‘my_pages_columns’ );
[/html]

To do the same thing for the pages just change the function to manage_pages_columns. And here is the output:

add-remove-column-wordpress

Author: mytutorialguru

Share This Post On

Submit a Comment

Your email address will not be published. Required fields are marked *