Exciting News! Flipper Code is now WePlugins! Same commitment to excellence, brand new identity.

How to use hidden_columns filter in WordPress

Sandeep Kumar Mishra
Sandeep Kumar Mishra
March 20, 2023
5 minutes read

Hey there! If you’re diving into WordPress development, hooks are your best friends. They allow you to modify or extend the functionality of WordPress without altering the core files. One such handy hook is the hidden_columns filter. Let’s explore how you can use it in a fun and easy way!

Example 1: Basic Usage of hidden_columns

In this example, we’ll see how to use the hidden_columns filter to modify the list of hidden columns on a screen.

    function weplugins_modify_hidden_columns_defaults($hidden, $screen, $use_defaults) { 
        // Update the $hidden variable according to your website requirements and return this variable.
        return $hidden; 
    }
    // add the filter
    add_filter( "hidden_columns", "weplugins_modify_hidden_columns_defaults", 10, 3 );
    

Example 2: Conditional Column Visibility

Here’s how you can conditionally change which columns are hidden based on the current screen.

    function weplugins_custom_hidden_columns($hidden, $screen, $use_defaults) {
        if ($screen->id == 'edit-post') {
            // Hide specific columns on the post edit screen
            $hidden[] = 'tags';
        }
        return $hidden;
    }
    add_filter('hidden_columns', 'weplugins_custom_hidden_columns', 10, 3);
    

Example 3: Removing the Hook

Sometimes, you might need to remove a filter. Here’s how you can remove the hidden_columns filter.

    remove_filter( "hidden_columns", "weplugins_modify_hidden_columns_defaults", 10, 3 );
    

Ensure you provide the same callback function name, priority, and number of arguments while removing the hook callback.

Access Premium WordPress Plugins

If you’re looking for more customization or need help implementing hooks like these, feel free to Contact Us. Our team at WePlugins is always ready to assist you with your WordPress development needs!

Sandeep Kumar Mishra

Sandeep Kumar Mishra

Sandeep Kumar Mishra writes about WordPress and Artificial Intelligence, offering tips and guides to help you master your website and stay updated with the latest tech trends.

Explore the latest in WordPress

Trying to stay on top of it all? Get the best tools, resources and inspiration sent to your inbox every Wednesday.