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

How to use postbox_classes_page_id filter in WordPress

Sandeep Kumar Mishra
Sandeep Kumar Mishra
March 22, 2023
5 minutes read
postbox_classes_page_id filter lets you modify postbox classes for a specific screen and screen ID. It’s super handy when you need to tweak the appearance or behavior of postboxes on different admin pages. This hook has two dynamic parameters: $page and $id, which correspond to the screen and screen ID.

Access Premium WordPress Plugins

Description:

This filter allows customization of postbox classes for a specific screen and screen ID combo. With dynamic parameters $page and $id, it offers flexibility for targeting specific admin pages.

Parameters:

  • $classes : (string[]) An array of postbox classes.

Example 1: Adding a Class to Postbox

Here’s how you can add an additional class to the postbox using this filter.

            add_filter('weplugins_postbox_classes_post_postexcerpt','weplugins_add_metabox_classes');

            function weplugins_add_metabox_classes($classes) {
                array_push($classes, 'another_class');
                return $classes;
            }
            

Example 2: Removing a Class from Postbox

Need to remove a class from the postbox? Check out this example.

            // remove the filter 
            add_filter('weplugins_postbox_classes_post_postexcerpt', 'weplugins_add_metabox_classes', 10, 1);
            

Example 3: Customizing Postbox Classes Further

Take customization a step further by manipulating the postbox classes based on conditions.

            add_filter('weplugins_postbox_classes_page_custom', 'weplugins_customize_postbox_classes');

            function weplugins_customize_postbox_classes($classes) {
                if (some_condition()) {
                    $classes[] = 'custom_class';
                }
                return $classes;
            }
            

Contact Us:

If you need any customization or have queries, feel free to Contact Us.

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.