WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] Verve Meta Boxes, and value stored in checkbox

[Resolved] Verve Meta Boxes, and value stored in checkbox

  • Hello;
    In the Verve Meta Boxes, i use the “checkbox” as “Field type“, and then i enter the “values” like this : product01,product02,product03,product04,product05

    In my post, i check the box for : product02 & product04.

    In my theme, i use this code to show the “values” i select

    <?php if($var_offres !== '') { ?>
    	<li><?php echo $var_offres; ?></li>
    <?php } ?>

    but it show only the last value : product04 !

    so i try to use the foreach, but it dont work, this is the code :

    <?php $var_offres = get_post_meta($post->ID, "offres", TRUE); foreach($var_offres as $post) : ?>
    	<li>
    		<?php echo $var_offres; ?>
    	</li>
    <?php endforeach; ?>

    and this

    <?php $var_offres = get_post_meta($post->ID, "offres", TRUE); foreach($var_offres as $post) : ?>
    		<?php if($var_offres !== '') { ?>
    			<li><?php echo $var_offres; ?></li>
    		<?php } ?>
    <?php endforeach; ?>

    pls how can i liste all the value i select?

    Thanks

Viewing 4 replies - 1 through 4 (of 4 total)
  • taghaboy

    @taghaboy

    any idea pls!

    avenueverve

    @avenueverve

    hi taghaboy,

    when you have multiple values, you will need them back in an array. so do put FALSE in get_post_meta, rather than TRUE (TRUE returns a single value). Also change the foreach statement to:

    foreach($var_offres as $offre) :

    here is the complete code snippet:

    <?php $var_offres = get_post_meta($post->ID, "offres", FALSE); foreach($var_offres as $offre) : ?>
    		<?php if($offre !== '') { ?>
    			<li><?php echo $offre; ?></li>
    		<?php } ?>
    <?php endforeach; ?>
    taghaboy

    @taghaboy

    thanks for the reply, i will test it.

    taghaboy

    @taghaboy

    yes it work.
    thanks

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘[Resolved] Verve Meta Boxes, and value stored in checkbox’ is closed to new replies.