Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialDanny Outlaw
677 PointsCustom Metaboxes Checkboxes
I cant seem to figure out how to echo checkboxes?
I have a setting on pages to hide the logo. I have the code below in a css/php file
<?php if ( $meta_boxes ['wpex_hide_logo'] == '1') { echo "#logo {display:none !important;}";} ?>
Currently using CMB2 https://github.com/WebDevStudios/CMB2
For refrence
$meta_boxes[] = array(
'id' => 'wpex-hide-meta',
'title' => __( 'Feature Settings', 'wpex' ),
'pages' => array( 'page' ),
'context' => 'normal',
'priority' => 'high',
'show_names' => true,
'fields' => array(
array(
'name' => __( 'Test Checkbox', 'cmb2' ),
'desc' => __( 'field description (optional)', 'cmb2' ),
'id' => $prefix . 'hide_logo',
'type' => 'checkbox',
),
),
);
Danny Outlaw
677 PointsFigured it out
<?php if(get_post_meta( get_the_ID(), 'wpex_hide_logo', true )) {echo "#logo {display:none !important;}";} ?>
Danny Outlaw
677 PointsDanny Outlaw
677 PointsGetting closer
This hides the logo even if the check box is not checked
<?php if($wpex_hide_logo = get_post_meta( get_the_ID(), 'wpex_text', true )) {echo "#logo {display:none !important;}";} ?>