2015-09-09 75 views
0

我無法在WordPress中使用acf(選擇多個)獲取分類的名稱。Wordpress顯示分類與acf

$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" 
    } 
} 
+0

能否請你解釋關於你的問題多一點,以便我們可以幫助你? –

回答

0

你有數據......你只需要使用標準的foreach循環來顯示它:

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

謝謝,它的工作原理 –