Display custom taxonomy in dropdown list or link format

Basically, we use get_terms() method to display custom taxonomy in dropdown list or link format. We get all terms of custom taxonomy in array format and then we are display terms in dropdown list or in link format using foreach loop.

Here, i will show you how we can display custom taxonomy in dropdown list or link format using some defaults wordpress functions.

 

1. wp_dropdown_categories() : Using this function, we can display custom taxonomy in dropdown list. By default, this function display default taxonomy “Category”. But we can use this function for custom taxonomy. For example,

wp_dropdown_categories( array( 'taxonomy' => 'custom_taxonomy_slug_here' ) );

Here, we pass slug of custom taxonomy. To know more arguments of this function go to this link. http://codex.wordpress.org/Function_Reference/wp_dropdown_categories

 

2. wp_list_categories() : Using this function, we can display list of custom taxonomy as links in <ul><li> format. For example,

wp_list_categories( array( 'taxonomy' => 'custom_taxonomy_slug_here' ) );

Here also, we pass slug of custom taxonomy. To know more arguments of this function go to this link. http://codex.wordpress.org/Function_Reference/wp_list_categories

 

Using this post i just want to say that, we can use default wordpress functions to accomplish our work instead of wrtiting custom code.