I have a trouble with a type of checkbox-list in meta-box. This is my code in meta-box-config.php:

$meta_boxes[] = array(
'id'        => 'poker_room_extension',
'title'     => 'Poker Room Options',
'pages'     => array( 'post', 'page' ),

'fields'    => array(

        'name'      => 'Sistema operativo supportato',
        'id'        => $prefix . 'os_poker_room',
        'clone'     => false,
        'type'      => 'checkbox_list',
        'options'   => array(
            'windows'     => 'Windows ',
            'mac' => 'Mac ',
            'linux' => 'Linux '
        'std'       => false

This is what I see in my post's options

enter image description here

enter image description here

Is it normal that variable omc_os_poker_room is the same? How I can show the values? Is omc_os_poker_room an array or not? I don't understand.

If I run this code in my template it show only the first value (windows and not the other ones checked):

$omc_os_poker_room =  get_post_meta(get_the_ID(), 'omc_os_poker_room', true);
$conta = count($omc_os_poker_room);

        <?php if ($omc_os_poker_room != '') {
            echo '<p class="omc-info-one"><b>OS: </b>';
            for($i=0;$i<$conta;$i++) {
            echo $omc_os_poker_room[$i];
            } }?>

Can you help me? Thanks

I replaced this line:

$omc_os_poker_room =  get_post_meta(get_the_ID(), 'omc_os_poker_room', true);


$omc_os_poker_room =  get_post_meta(get_the_ID(), 'omc_os_poker_room', false);

It's working now! ;)

1 Answer 1


The issue is probably with the $single parameter of get_post_meta function. Try setting it to false or delete it. Codex Link


$omc_os_poker_room =  get_post_meta(get_the_ID(), 'omc_os_poker_room');
    echo '<p class="omc-info-one"><b>OS: '.$omc_os_poker_room[1].'</b>';

Not tested, but should work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.