• Hello,

    Not sure if this is in the correct forum section, please move it if I’m wrong.

    I’m using add_meta_box in my custom code, but I don’t see a way to add a class to my box.

    <div id=”myCustomName” class=”postbox pleaseLetMeAddCustomClass”>

    Currently, only a class of “postbox” is generated. I need the class at this level, and not lower down in the generated “inside” content.

    Is there a way to do this? Or would this be a feature request?

    • This topic was modified 2 years, 3 months ago by Jan Dembowski.
Viewing 3 replies - 1 through 3 (of 3 total)
  • @j3gaming Could you provide a little more information about where you’re looking to add the class and the intended outcome? Is this for the Classic Editor? Gutenberg? The reason I ask is add_meta_box() allows you to pass a custom callback for outputting specific HTML for the meta box, so you should have the flexibility you need there.

    If you’re looking to add the class to the wrapper div, that might be a little more challenging, as I don’t see any hooks to filter the wrapper divs. You could hook in some JavaScript that selects the div by ID and then modify its parent and add classes that way if you’re comfortable writing JavaScript code.

    Thread Starter j3gaming

    (@j3gaming)

    @bengreeley I’m trying to add it here:
    https://i.imgur.com/uN0hYHK.png (“postbox closed AddNewOneHere”)

    I’m currently using wp_add_dashboard_widget, but it looks like I could adjust and use add_meta_box() for a similar effect.

    This would be on the main page of the dashboard, wp-admin/index.php

    • This reply was modified 2 years, 3 months ago by j3gaming.

    You should still be able to pass $callback and $control_callback to wp_add_dashboard_widget() and likely customize the HTML classes that you need.

    Cheers.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘add_meta_box Add custom class’ is closed to new replies.