Contact!

Removing columns from pages and post tables in WordPress

So you’ve installed Yoast (or some other plugin) and now your post columns are unmanageable?

This problem is normally caused when you have too many plugins adding to the post columns of the post table view.

Thankfully I have a solution for you!

To begin with we will need to open our theme or plugin functions.php and create a function to handle removing the unwanted columns.

function remove_yoast_columns($columns) {

}

We can then use <a>php unset</a> to remove the entry from the $columns array being passed. I am removing the ‘wpseo-score’ and ‘wpseo-score-readability’ variables.

function remove_yoast_seo_columns($columns) {

    // Remove Score
    unset($columns['wpseo-score']);

    // Remove Score Readability
    unset($columns['wpseo-score-readability']);

    return $columns;

}

Finally we need to hook a filter to use our remove function. The syntax is as follows:

add_filter('manage_[post_type]_posts_columns', '[function_name]', [priority?]);

For our example the code looks like this:

add_filter('manage_product_posts_columns' , 'remove_yoast_columns', 11);

Congratulations! Your post tables should now be easier to maintain.

N.B. Some other things that you might want to remove (depending on whether you are using them):

// Remove Author
unset($columns['author']);

// Remove Tags
unset($columns['tags']);

// Remove Comments
unset($columns['comments']);

Join the discussion!

You might like:

Create, register and use shortcodes in WordPress

Create, register and use shortcodes in WordPress

by Gav 18/03/2023

Learn how to create and register your own WordPress shortcodes to add dynamic content to your posts and pages.

How to use guard clauses in JavaScript

How to/why use guard clauses in JavaScript

by Gav 16/03/2023

Learn how to improve code readability and performance by using guard clauses in JavaScript. Discover their benefits and best practices.

Implements and Extends, Object Oriented TypeScript

Implements and Extends, Object Oriented TypeScript

by Gav 15/03/2023

Learn the difference between implements and extends in TypeScript. Use Implements to implement interfaces and types, and extends to inherit from classes.

Reading/Parsing and Writing YAML files in PHP, Symfony

Reading/Parsing and Writing YAML files, PHP Symfony

by Gav 14/03/2023

In this tutorial we will look at using YAML in PHP. Learn about Parsing and Writing YAML files using Symfony's YAML component.

Measuring code execution performance in JavaScript

Measuring code execution performance in JavaScript

by Gav 13/03/2023

Measuring code execution performance is an important way to identify bottlenecks. Use these methods in JavaScript to help optimise your code.

Measuring script/code execution time in PHP using microtime

Measuring script/code execution time in PHP, microtime

by Gav 06/03/2023

Find bottlenecks, optimise and clean your code, and speed up your apps by measuring the execution time of your PHP scripts using microtime.

Regenerate WordPress media image sizes, programmatically

Regenerate WordPress media image sizes, programmatically

by Gav 25/02/2021

Learn how to regenerate and update WordPress media and image sizes both programmatically (without plugin), and also with a handy plugin.

Magic Constants in PHP. What they are and how to use them.

Magic Constants in PHP. What they are and how to use them

by Gav 15/02/2021

Ever seen constants like __DIR__ and __FILE__ being used in PHP? These are 'Magic Constants', and this is how we can use them.

Detecting Keypress JavaScript

Detect single and multiple keypress events: JavaScript

by Gav 16/10/2019

Learn how to use event listeners to detect and handle single and multiple keypress events in JavaScript. Add modifier keys to your application!