Php ACF返回复选框的值-非标签
我在functions.php文件中运行以下命令:Php ACF返回复选框的值-非标签,php,wordpress,advanced-custom-fields,Php,Wordpress,Advanced Custom Fields,我在functions.php文件中运行以下命令: $query = new WP_Query(array( 'post_type' => 'gear', 'orderby' => 'title', 'order' => 'ASC', 'author' => $current_user->ID, 'posts_per_page' => -1, 'meta_key' => 'brand_pr
$query = new WP_Query(array(
'post_type' => 'gear',
'orderby' => 'title',
'order' => 'ASC',
'author' => $current_user->ID,
'posts_per_page' => -1,
'meta_key' => 'brand_preselect',
'orderby' => 'meta_value',
'meta_key' => 'category_tax',
'orderby' => 'meta_value',
));
foreach($query->posts as $product_id=>$macthed_product){
$choices[$macthed_product->ID] = '<span>' . $macthed_product->brand_preselect . '</span>' . $macthed_product->post_title;
}
$query=新的WP\u查询(数组)(
“立柱类型”=>“齿轮”,
'orderby'=>'title',
“订单”=>“ASC”,
'author'=>$current\u user->ID,
“每页帖子数”=>-1,
“元键”=>“品牌预选”,
'orderby'=>'meta_value',
“元密钥”=>“类别税”,
'orderby'=>'meta_value',
));
foreach($query->posts as$product\u id=>$macthed\u product){
$choices[$macthed\u product->ID]='.$macthed\u product->brand\u preselect'.$macthed\u product->post\u title;
}
这一切都很好,但问题是$macthed_product->brand_preselect返回的是复选框的值,而不是标签。在这个字段(brand_preselect)上,我只将其设置为返回标签。如何让它返回标签而不是值?通过CBroe解决-$zz=get\u字段('brand\u preselect',$macthed\u product->ID) 创建数据后是否更改了字段设置?Fieldsettings不会更新过去的设置值。不确定您的意思是什么?我基本上使用的解决方案发布在:“在此字段(brand_preselect)上,我只将其设置为返回标签。”-这仅适用于使用ACF方法获取字段值的情况;但是,在这里,您自己直接查询数据库。为什么不呢?解释这样的东西,而不是仅仅说明它,好像它是一个实际的事实。你需要传递post ID作为第二个参数。这里没有“当前帖子”,这只是在实际的WP循环中工作时的事情。