• Resolved mael

    (@mael)


    Using checkboxes like in the example :
    [Favorite Fruits]
    type = checkbox
    value = apple # orange # banana # grape
    default = orange # grape

    I try do display the selected items, but only the first checked one (for instance “apple”) appears in html.
    I call the field like this :
    <?php echo get_post_meta($post->ID, 'Favorite Fruits', true); ?>
    something wrong ?
    (I’m not a php guy, only html/css and wp template tags…)
    Thanks !

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter mael

    (@mael)

    Found !
    The array can be returned with “get_post_custom_values“.
    I used this within the loop :

    <?php  $mykey_values = get_post_custom_values('Your-Key-Here');
    foreach ( $mykey_values as $key => $value ) {
    echo "<li class=\"A -Class-Name\"> $value</li>";
    } ?>

    I hope it can help Everyone ?? !

    thx!

    You could also try

    <?php echo get_post_meta($post->ID, 'Favorite Fruits', false); ?>

    …with the last argument FALSE instead of true. That argument tells the function whether or not to return a single value.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Plugin: Custom Field Template] output of checkboxes’ is closed to new replies.