Print something if value exist in metabox multicheck
-
Hi im using this framework for my metaboxes.
I have custom post type ‘products’ and i added multicheck metabox to it, for every checkbox i want to print an image in frontend. But somehow im getting all images printed even if none of checkboxes in my metabox multicheck are on.
This is metabox:$meta_boxes[] = array( 'id' => 'product_page', 'title' => 'Product Options', 'pages' => array('products',), // Post type 'context' => 'normal', 'priority' => 'high', 'show_names' => false, // Show field names on the left 'fields' => array( array( 'name' => 'Product Features', 'id' => $prefix . 'product_features', 'type' => 'multicheck', 'options' => array( 'check1' => 'DPF', 'check2' => 'OEM', ) ), ) );
So i have different image for every value, and i want to print that image is checkbox is on.
This is my full query:
<?php $type = 'products'; $args = array( 'post_type' => $type, ); $my_query = null; $my_query = new WP_Query($args); if ($my_query->have_posts()) { while ($my_query->have_posts()) : $my_query->the_post(); ?> <div class="grid"> <div class="prod-range"> <div class="col col-3-4 prod-desc"> <h3 class="first"><?php the_title(); ?></h3> <div class="features"> <?php global $post; $key = '_cmb_product_features'; $themeta1 = get_post_meta($post->ID, $key, TRUE); if($themeta1 != 'check1') { ?> <img src="<?php bloginfo('template_url'); ?>/assets/images/content/range-type1.png" alt="type1"> <?php } ?> <?php global $post; $key = '_cmb_product_features'; $themeta2 = get_post_meta($post->ID, $key, TRUE); if($themeta2 = 'check2') { ?> <img src="<?php bloginfo('template_url'); ?>/assets/images/content/range-type2.png" alt="type1"> <?php } ?> </div> <a href="<?php the_permalink(); ?>" class="readmore first">find out more</a> </div> </div> </div> <?php endwhile; } wp_reset_query(); // Restore global post data stomped by the_post(). ?>
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Print something if value exist in metabox multicheck’ is closed to new replies.