dimanche 15 mars 2015

Wordpress checkboxes array

I've made some new checkbox fields in my wordpress template using Meta box. Now i want to display those selected checkboxes in the fronttend, but it will display only the first checkbox that i've checked, not the other ones.


The problem seems to by the array functions that displays only the first checkbox.


From wordpress codex i saw that my third parameter "true" is (boolean) (optional) If set to true then the function will return a single result, as a string. With all that i can't get my code to work properly :(.


This is the code from meta-box-config.php



array(
'name' => 'Genearal',
'id' => "{$prefix}utilitati_general",
'clone' => false,
'type' => 'checkbox_list',
'options' => array(
'Curent Electric' => __('Curent electric','locality'),
'Telefon' => __('Telefon','locality'),
'Apa' => __('Apa','locality'),
'Gaz' => __('Gaz','locality'),
'Cablu TV' => __('Cablu TV','locality'),
'Canalizare' => __('Canalizare','locality')
),
'std' => false
),


This is the code that i've use in the frontpage



$locality_utilitati_general = get_post_meta($post->ID,'locality_utilitati_general', true);
if(!empty($locality_utilitati_general))
{
?>
<?php _e('General: ','locality'); ?><?php echo $locality_utilitati_general; ?>
<?php
}




Aucun commentaire:

Enregistrer un commentaire