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 !
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 :) !
knivesOut
Member
Posted 2 years ago #
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.