Remove columns from the WordPress Admin posts screen

When building WordPress websites something that I’m asked more and more frequently is whether its possible to hide or remove columns from the posts, pages and custom posts admin screens. The most common requests are to remove the comments column because that particular site doesn’t have comments, or if there is only one author for the website that column may not be needed.

By using the following snippet of code we can do that very easily.


function remove_comments_column( $columns ) {
unset($columns['comments']);
return $columns;
}

function remove_column_init() {
add_filter( 'manage_posts_columns' , 'remove_comments_column' );

}
add_action( 'admin_init' , 'remove_column_init' );

To remove a different column, for example: Author, all we need to do is change line 2 to

unset($columns['author']); 

instead.

Simples 🙂

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.

Up ↑

%d bloggers like this: