Wordpress显示分类与acf

时间:2015-09-09 19:41:33

标签: wordpress advanced-custom-fields

我无法在WordPress中使用acf(选择Multiple)获取分类法的名称。

$categories_user = get_field('product__services', $company_id);

当我var_dump($categories_user)输出时:

array(2) { 
    [0]=> object(stdClass)#3816 (10) { 
        ["term_id"]=> int(28) 
        ["name"]=> string(17) "sous category 2-4" 
        ["slug"]=> string(17) "sous-category-2-4" 
        ["term_group"]=> int(0) 
        ["term_taxonomy_id"]=> int(28) 
        ["taxonomy"]=> string(11) "project_cat" 
        ["description"]=> string(0) "" 
        ["parent"]=> int(25) 
        ["count"]=> int(2) 
        ["filter"]=> string(3) "raw" 
    } 
    [1]=> object(stdClass)#3818 (10) { 
        ["term_id"]=> int(34) 
        ["name"]=> string(13) "Ywz categorie" 
        ["slug"]=> string(13) "ywz-categorie" 
        ["term_group"]=> int(0) 
        ["term_taxonomy_id"]=> int(34) 
        ["taxonomy"]=> string(11) "project_cat" 
        ["description"]=> string(0) "" 
        ["parent"]=> int(0) 
        ["count"]=> int(0) 
        ["filter"]=> string(3) "raw" 
    } 
} 

1 个答案:

答案 0 :(得分:0)

您拥有数据......您只需使用标准foreach循环显示它:

foreach ( $categories_user as $cat ) {
    echo $cat->name;
}