How to Remove Post Columns in WordPress: A Detailed Guide

Home » Snippets » How to Remove Post Columns in WordPress: A Detailed Guide
0

Created with:

Visibility: 

public

Creator: WPTurbo Team

Customize with WPTurbo AI
X

Add Snippet To Project

New Project
Add To Existing Project

As a WordPress site owner, a clean and accessible administrative dashboard can make your website management experience much smoother. One way to streamline your dashboard is by removing unneeded post columns. Whether they’re default columns that WordPress provides or columns added by a plugin, cluttering your display area with redundant information can tamper with your productivity. This guide will show you the easy steps to eliminate unnecessary post columns, making your WordPress management efficient and effective.

					function wpturbo_remove_post_columns( $columns ) {
    unset($columns['tags']);
    unset($columns['comments']);
    return $columns;
}
add_filter( 'manage_posts_columns' , 'wpturbo_remove_post_columns' );
				

The provided PHP code snippet is used to remove specific columns from the ‘All Posts’ page in the WordPress admin area. Here’s how it works:

First, we declare a custom function named wpturbo_remove_post_columns( $columns ). This function accepts one parameter: $columns.

function wpturbo_remove_post_columns( $columns ) { 
    ...
}

This $columns parameter is an associative array where the keys are the identifiers of the column, and the values are the translated column headings.

Within this function, we use the unset() function to remove items from the $columns associative array.

unset($columns['tags']);
unset($columns['comments']);

The unset() function in PHP allows you to remove variables or array elements. And we set this up to remove ‘tags’ and ‘comments’ columns – this is just an example, so you can specifically define which columns you want to remove by replacing ‘tags’ and ‘comments’ with the identifier of your unwanted column.

These unset functions will eliminate the columns named ‘Tags’ and ‘Comments’ from the ‘All Posts’ page within the WordPress admin. Note that these keys (tags and comments) refer to the column identifier, not the translated heading you see on the screen.

When the function has finished modifying the $columns array, we return it, which is required for the filter function to operate as expected:

return $columns;

Lastly, we attach our newly created function wpturbo_remove_post_columns, to the manage_posts_columns filter hook provided by WordPress.

add_filter( 'manage_posts_columns' , 'wpturbo_remove_post_columns' );

The manage_posts_columns is a filter applied to the columns that show in the All posts screen (edit.php), allowing you to alter or remove them. This means when WordPress loads the ‘All Posts’ page, it will execute our function, resulting in the desired columns being removed.

Register an account to save your snippets or go Pro to get more features.