简体   繁体   English

ACF 复选框的返回值 - 不是 label

[英]ACF Returning value of checkbox - not label

I am running the following in my functions.php file:我在我的 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_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;
}

This all works pretty well, but the problem is $macthed_product->brand_preselect is returning the value of the checkbox and not the Label.这一切都很好,但问题是 $macthed_product->brand_preselect 正在返回复选框的值,而不是 Label。 On this field (brand_preselect) I have it only set to return the Label though.在此字段(brand_preselect)上,我仅将其设置为返回 Label。 How do I get it to return the Label and not the value?如何让它返回 Label 而不是值?

Solved via CBroe - $zz = get_field('brand_preselect',$macthed_product->ID);通过 CBroe 解决 - $zz = get_field('brand_preselect',$macthed_product->ID);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM