我对meta box中的复选框列表类型有问题。这是我的密码meta-box-config.php:
$meta_boxes[] = array(
\'id\' => \'poker_room_extension\',
\'title\' => \'Poker Room Options\',
\'pages\' => array( \'post\', \'page\' ),
\'fields\' => array(
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
)
)
);
这是我在帖子的选项中看到的
变量omc\\u os\\u poker\\u room相同,这正常吗?如何显示值?omc\\u os\\u poker\\u room是否为阵列?我不明白。
如果我在模板中运行此代码,它将仅显示第一个值(windows,而不是选中的其他值):
$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];
} }?>
你能帮帮我吗?谢谢
我替换了这一行:
$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);
它现在正在工作!;)