Jelena P
Jelena P

Reputation: 59

Meta box plugin WordPress

I'm using Meta box plugin for WordPress and don't understand how to make fields output appears in pages. I want to use checkbox to add/remove div's class. For example this is code for my page template:

<?php
<div class="HOW TO APPEAR CLASS FROM META BOX CHECK BOX HERE??">
<?php the_content(); ?>
</div> 
?>

and this is metabox array from metabox plugin:

array(
'name' => __( 'Checkbox', 'rwmb' ),
'id' => "{$prefix}checkbox",
'type' => 'checkbox',
// Value can be 0 or 1
'std' => 1,
),

How to add class in page?

Upvotes: 0

Views: 704

Answers (1)

cpilko
cpilko

Reputation: 11852

Try something like this:

<?php
$my_metabox = rwmb_meta('checkbox_meta_key'); //Replace checkbox_meta_key with the key you defined.
?>
<div class="<?php if($my_metabox) echo "my-class"; ?>" > 

Upvotes: 1

Related Questions