I want to show a custom taxonomy in the name of custom_tax in a plugin option page as dropdown that user can select terms of taxonomy. I know that I can use wp_dropdown_categories() but I don't want show the terms of category taxonomy. I'm going to show my custom taxonomy terms as dropdown. Is there any function to do that? or no how can I do that?
2 Answers
wp_dropdown_categories()
has the taxonomy
parameter, which defaults to category
, but can be used to retrieve custom taxonomies. Exemplary usage:
wp_dropdown_categories([
'taxonomy' => 'custom-taxonomy-name'
]);
get_terms() function should help you. An example:
$terms = get_terms( array(
'taxonomy' => 'custom_tax',
) );