WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have an situation: I just can't figure out how to add classes to some meta boxes.
I read these post from here, I tried this solution, but it did not work as I wanted. Is there a way to add classes (to customize them in CSS) to meta boxes?
For example in this case:

    'label' => 'a name',
    'desc'  => 'description',
    'id' => 'id_x',
    'type' => 'select',
    'options' => array('Bad', 'Good', 'Excellent'), /* HERE I WANT A CLASS FOR EACH THIS GUYS (to customize them in CSS) */
    'std' => "

I want that the HTML to look like this:

<span class="bad">Bad</span>
<span class="good">Good</span>
<span class="excellent">Excellent</span>
share|improve this question

Answer given in your link is perfectly correct, you set it this way :

add_filter( 'postbox_classes_{post_type_name}_{metabox_id}', 'add_metabox_classes'  );

function add_metabox_classes($classes) {
  return $classes;
share|improve this answer
So, I must add this filter in "function.php" and change this: "post_type_name" and "metabox_id", right? Just all? – Blanka Aug 29 '13 at 13:34
and 'another class' to your class too. – JMau Aug 29 '13 at 14:39
How should be 'another_class'? I do not know what to write in "another_class". Can you be more specific, please? – Blanka Aug 29 '13 at 15:13
If you want to use CSS class, replace your_class with your custom class and then style it. – JMau Aug 29 '13 at 15:37
{post_type_name} and {metabox_id} are example values, use the actual values in their place.. (without the curly quotes). – t31os Aug 29 '13 at 18:38

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.