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

How to use hidden_meta_boxes filter in WordPress

Sandeep Kumar Mishra
Sandeep Kumar Mishra
April 8, 2023
5 minutes read

When working with WordPress, hooks are a vital part of customizing and extending the functionality of your website. One such hook is the hidden_meta_boxes filter. This filter is used to control the list of hidden meta boxes on the WordPress admin screens. Let’s dive into how you can utilize this hook effectively.

Example 1: Modifying Hidden Meta Boxes

In this example, we’ll see how to modify the default hidden meta boxes. The function weplugins_modify_hidden_meta_boxes_defaults is created to adjust the array of hidden meta boxes.

    function weplugins_modify_hidden_meta_boxes_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_meta_boxes", "weplugins_modify_hidden_meta_boxes_defaults", 10, 3 );
    

Example 2: Removing a Hook Callback

If you need to remove an existing hook callback, you can do so using the remove_filter function. This is useful when you want to stop a specific function from modifying the hidden meta boxes.

    remove_filter( "hidden_meta_boxes", "weplugins_modify_hidden_meta_boxes_defaults", 10, 3 );
    

Example 3: Conditional Modification of Meta Boxes

Here’s an example where the hidden meta boxes are modified conditionally based on the current screen.

    function weplugins_conditional_hidden_meta_boxes($hidden, $screen, $use_defaults) {
        if ($screen->id == 'post') {
            // Modify $hidden for post screen
        }
        return $hidden;
    }
    add_filter( "hidden_meta_boxes", "weplugins_conditional_hidden_meta_boxes", 10, 3 );
    

Remember, using hooks like hidden_meta_boxes allows you to customize your WordPress site without altering core files, ensuring your changes remain intact during updates.

Access Premium WordPress Plugins

Contact Us if you need any customization or help with WordPress hooks. Visit our contact page for further assistance.

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.