function get_people_cats($taxonomy) {
$output = '';
$terms = get_terms($taxonomy);
$count = count($terms);
if ($count > 0):
foreach ($terms as $term):
$output .= "'". $term->name ."'". '=>';
$output .= "'". $term->term_id."',";
endforeach;
endif;
return $output;
}
此函數返回自定義分類列表,如果函數在模板中調用,則返回哪個單詞。但我想將函數值分配給functions.php
中的變量,並且它什麼都不返回。函數在wordpress functions.php中輸出空值,但在從另一頁調用時起作用
感謝它適用於標準類別,但是當我輸入一個自定義分類作爲函數參數時,它返回這個:'array(「」=>「」,「」=>「」)' –
它不需要演講者圍繞關鍵和價值觀? –
在下面發佈了一個後續答案,以便代碼格式化爲 – wunderdojo