WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Verve Meta Boxes, and value stored in checkbox (5 posts)

  1. taghaboy
    Member
    Posted 3 years ago #

    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

  2. taghaboy
    Member
    Posted 3 years ago #

    any idea pls!

  3. avenueverve
    Member
    Posted 3 years ago #

    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; ?>
  4. taghaboy
    Member
    Posted 3 years ago #

    thanks for the reply, i will test it.

  5. taghaboy
    Member
    Posted 3 years ago #

    yes it work.
    thanks

Topic Closed

This topic has been closed to new replies.

About this Topic