Is there a way to prevent WordPress from automatically wrapping every metabox in the postbox class? Or at least add my own outer div so I can make custom changes via css? Thanks!
Leave a Reply
You must be logged in to post a comment.
Is there a way to prevent WordPress from automatically wrapping every metabox in the postbox class? Or at least add my own outer div so I can make custom changes via css? Thanks!
You must be logged in to post a comment.
Here is an answer how to modify the css classes of metaboxes. I would not remove the postbox class, because it is needed to open and close the metabox. But you can attach your own css class to style the metabox and the following html elements.
But you have to modify every single metabox, there is no general hook for all metaboxes. Use the global
$wp_meta_boxes
to find out which metaboxes are available on the current screen.This code will add the
closed
class to all metaboxes on the dashboard, so all metaboxes will be displayed minified.Add your necessary classes with the
postbox_classes_{$page}_{$id}
filter. For example…That will add your class to the “Submit” meta box– the one with the “Publish” header– on the “Post” edit page. You can get those values by looking at the source of the page. The
{$page}
part is revealed in a bit of Javascript near the top. Look forpagenow
. The {$id} is the metabox<div>
‘s id attribute.