我有一個自定義的帖子類型,它具有一個名爲「country」的自定義分類。我需要在儀表板 - >主題選項中的下拉列表中選擇該分類下的術語名稱。所以,我創建了以下功能:如何在WordPress的管理選項中的下拉列表中顯示條目
function featured_country($show_count = false, $country_array = array()) {
$countries = get_terms('category', 'hide_empty=0&fields=all');
foreach ($countries as $countr) {
$country_array[$countr->term_id] = $countr->name;
}
return $country_array;
}
然後我調用這個函數如下:
$this->admin_option('Front Page Option',
'Featured country', 'featured_country',
'select', '',
array('options'=>$this->featured_country(true, array(''=>'Select Category')),
'help'=>'Some helping text')
);
不幸的下拉列表中顯示什麼。但是,當我把get_terms()的參數設置爲「category」或「link_category」時,它就起作用了。
我不明白我的問題在哪裏。我該如何解決這個問題?請幫幫我。