How to Disable a Specific Column in WordPress Post Type Admin
Custom post types in WordPress are incredibly useful for organizing content, but sometimes, the default admin columns can clutter the interface. If you have a specific column that you want to disable from the post type admin screen, WordPress provides an easy way to do this with hooks and filters.
Why Remove Columns in the Admin Dashboard?
There are several reasons why you might want to remove a specific column from the admin post type screen:
- Improved usability – Too many columns can make the admin panel feel cluttered and overwhelming.
- Increased performance – Some columns require extra database queries, which may slightly slow down page load times.
- Better user experience – Hiding unnecessary columns ensures that only relevant information is displayed to your content managers.
Disabling a specific column is a simple and clean way to enhance the efficiency of your WordPress admin panel.
Using the manage_edit-{post_type}_columns Filter
One of the most straightforward ways to remove a column from a custom post type admin screen is by using the manage_edit-{post_type}_columns
filter.
To remove a specific column using this method, follow these steps:
Step 1: Identify the Column Key
Before removing a column, you need to determine its key. The column keys are the array keys of the columns managed by WordPress. You can find these keys by adding this temporary code to your theme’s functions.php
file:
add_filter('manage_edit_your_post_type_columns', function($columns) {
print_r($columns);
return $columns;
});
Open the WordPress admin panel and navigate to your custom post type list. The printed array will show the column keys.

Step 2: Remove the Column
Once you identify the column you want to disable, you can modify the filter to remove it. For example, to remove the author
column from a custom post type called books
, use this code:
function remove_specific_column($columns) {
unset($columns['author']); // Replace 'author' with the key of the column you want to remove
return $columns;
}
add_filter('manage_edit_books_columns', 'remove_specific_column');
Step 3: Save and Test
Save the functions.php
file and refresh your custom post type admin screen. The specified column should now be removed.
Disabling Columns Using the Admin Screen Options
If you don’t want to modify theme files, another option is to disable the column from the screen options available in the WordPress admin.
- Navigate to the post type admin screen (e.g., Books).
- Click on the Screen Options button in the top-right corner.
- Uncheck the column you don’t need.
- The change applies immediately.
While this method hides the column for the current user, it does not remove it entirely for other users.

Removing Columns Programmatically for All Users
If you need a global solution that applies to all users, the unset()
function inside the manage_edit_{post_type}_columns
filter is the best approach.
For example, to remove multiple columns from a post type called movies
, use the following code:
function remove_multiple_columns($columns) {
unset($columns['author']);
unset($columns['comments']);
unset($columns['date']);
return $columns;
}
add_filter('manage_edit_movies_columns', 'remove_multiple_columns');
This ensures the specified columns are not displayed for any user in the admin panel.
Ensuring Compatibility with Plugins
Some third-party plugins add custom columns to post type screens. If you are removing columns using code, ensure that the column key you remove does not interfere with essential plugin functionality.
The best way to verify is by temporarily enabling the debug log and checking if there are any conflicts.
Enable WP Debug Mode
Add this line to your wp-config.php
file:
define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);
Review the debug log file in /wp-content/debug.log
for any errors related to missing columns.
Final Thoughts
Disabling specific columns in WordPress admin post type screens is a simple way to improve the usability and efficiency of your dashboard. By using the manage_edit_{post_type}_columns
filter, you can easily remove unnecessary columns programmatically and tailor the interface to fit your needs.
For one-time adjustments, the Screen Options menu is sufficient, but for maintaining a structured workflow across all users, adding the correct filters in your theme’s functions.php
file is a more effective solution.

By keeping your admin panel organized, you can enhance productivity and create a streamlined content management experience. Implement these steps today to take control of your WordPress admin interface.
Comments are closed, but trackbacks and pingbacks are open.