I have a custom post type which has a custom taxonomy called “country”. I want a drop-down list in the Dashboard -> Theme Option to select the term name under this taxonomy. So I have created the following function:
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;
}
Then I call this function as follows:
$this->admin_option('Front Page Option',
'Featured country', 'featured_country',
'select', '',
array('options'=>$this->featured_country(true, array(''=>'Select Category')),
'help'=>'Some helping text')
);
Unfortunately this drop-down list displays nothing. But when I put the parameter of get_terms() as âcategoryâ or “link_category” it works.
I can not understand where is my problem. How can I solve this? Please help me.
Try out this code
(I took it from this forum thread)
Here’s the example where Custom taxonomy” is courses” & custom post type for that is “help_lessions“