我在Wordpress中创建了一个元框,其中包含自定义字段,包括复选框。我不确定如何检查我的模板中选中了哪个复选框。
自定义字段
array(
"name" => "offer-type",
"title" => "Type of offer",
"description" => "Please select what kind of offer this is",
"options" => array( "TYPE A","TYPE B"),
"type" => "checkbox",
"scope" => array( "post" ),
"capability" => "edit_posts"
),
我的模板循环
foreach ($posts as $day => $post) {
// 2 LINES BELOW ARE RELATED TO QUESTION
$offer_types = unserialize(get_post_meta($post->ID, "_mcf_offer-type", true));
echo var_dump($offer_types);
我的var转储正在返回" false" boolean,而它应该返回所选复选框的值。实施有问题吗?
答案 0 :(得分:1)
As per our extended discussions, try calling the post via $post('post_id')
I don't think you need the unserialize
either.
Your whole line would become:
$offer_types = get_post_meta($post['post_id'], "_mcf_offer-type", true);