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.

By Chandra Patel

I fell in love with WordPress in 2014 while freelancing as a web developer. I have grown since then to become a Core contributor, Translation contributor for Gujarati, and has contributed to WordPress Meta projects. Over the years, I have developed a love for learning, and hope to learn WordPress ever more “deeply”.

%d bloggers like this: