PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Checkboxes and Multiple Fields in wp_postmeta - How to Display Values on a Post?

  1. I've tried searching but haven't turned anything up, so apologies if I missed a previous question.

    I have a checkbox field that allows people to choose multiple meal options (breakfast, lunch, supper, etc.) which maps to a custom_field "meal-options". How do I then output all the options they might choose? Right now my code just spits out the first one. I know I'm missing some sort of loop but not sure how to do it properly.

    <h4>Meal Options Included</h4>
    <p>
    <?php $mealoptions = get_post_meta($post->ID,'meal-options', true);
    if ($mealoptions == 'false') {
    echo "Not at this time.";
    } else {
    echo get_post_meta($post->ID,'meal-options', true);
    }
    ?>
    </p>

    This is obviously part of a larger custom post type file.

    Posted 13 years ago on Friday December 16, 2011 | Permalink
  2. I'd like to know about this as well.

    Posted 12 years ago on Monday January 9, 2012 | Permalink