Beginner's Guide for WordPress - Start your WordPress Blog in minutes.
Choosing the Best
WordPress Hosting
How to Easily
Install WordPress
WordPress Plugins
View all Guides

How to Display Custom Taxonomy Terms in WordPress Sidebar Widgets

Last updated on by
Special WordPress Hosting offer for WPBeginner Readers
How to Display Custom Taxonomy Terms in WordPress Sidebar Widgets

WordPress has come a long way from being a simple blogging platform. With additions of custom post types and custom taxonomies, it is being used as a true content management system (CMS). In response from our article on how to create custom taxonomies in WordPress, some of our readers asked us how to display custom taxonomy terms in sidebar widgets. In this article we will show you how to display custom taxonomy terms in WordPress sidebar widgets.

We will show you how to display custom taxonomy terms in sidebar widgets using two different methods. The first method is by installing a plugin which is simpler and easier. We recommend using this method for majority of our audience. The second method involves creating your own shortcode. This method is for those who like to know how things work and have more control over the output.

Adding Custom Taxonomy Terms in a Widget (Plugin)

To display custom taxonomy terms in sidebar or other widget areas using a plugin, the first thing you need to do is install and activate Custom Taxonomies Menu Widget plugin. Upon activation, it adds a custom taxonomies menu widget under Appearance » Widgets. Drag and drop the widget to your sidebar. The widget configuration options allow you to choose the taxonomies you want to display or exclude. It also allows you to exclude terms inside a taxonomy.

Showing Custom Taxonomies in Sidebar using Widget

Adding Custom Taxonomy Terms with Shortcode

Custom Taxonomies Menu Widget plugin allows you to easily display terms from any custom taxonomy, without worrying about the code. However some users would want to learn how to do it manually, so that they could have more control on how terms for their custom taxonomy appears in their widgets. Furthermore, using the shortcode method allows you to display taxonomy terms within your post content should you need to.

First we need to create a shortcode that displays a list of terms and accepts parameters. The only parameter we need is the name of the taxonomy. Add this code in a site-specific plugin:

// First we create a function
function list_terms_custom_taxonomy( $atts ) {

// Inside the function we extract custom taxonomy parameter of our shortcode

	extract( shortcode_atts( array(
		'custom_taxonomy' => '',
	), $atts ) );

// arguments for function wp_list_categories
$args = array( 
taxonomy => $custom_taxonomy,
title_li => ''

// We wrap it in unordered list 
echo '<ul>'; 
echo wp_list_categories($args);
echo '</ul>';

// Add a shortcode that executes our function
add_shortcode( 'ct_terms', 'list_terms_custom_taxonomy' );

//Allow Text widgets to execute shortcodes

add_filter('widget_text', 'do_shortcode');

The code above creates a shortcode ct_terms that requires one parameter custom_taxonomy. To use this shortcode drag and drop a Text widget into your sidebar. Add this shortcode in your Widget and save.

[ct_terms custom_taxonomy=customtaxonomyname]

Replace customtaxonomyname with the name of the taxonomy you want to list.

We hope that you find this article useful in displaying custom taxonomy terms in your sidebar or other widget area. Let us know how you prefer to list terms of a custom taxonomy in the comments below.

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi. Page maintained by Syed Balkhi.

WPBeginner's Video Icon
Our HD-Quality tutorial videos for WordPress Beginners will teach you how to use WordPress to create and manage your own website in about an hour. Get started now »


  1. Muhammad Mobeen says:

    Hi WPbeginner,

    Thanks for the code. It works. BUT I’m using it to output the taxonomies into the posts and list structure doesn’t display well (goes to the top of the post).

    Please guide me how to output the taxonomies in a span instead of a list.

  2. deuts says:

    What if I want to display a “linked” top 10 used terms of my custom taxonomy in a period of time (e.g. the last 30 or 90 days)?

  3. siva says:

    Hi Team

    Which php file, i want save code. please tell me

  4. Chris says:

    Thank you!

    Saved me loads of time…..

  5. Julie says:

    Finally! An article that works. I have tried all different approaches, but yours is simple and functions. I styled the list so it mimicked the look of the theme sidebar links. Thanks for the article!!

  6. Nitin says:

    Thanks for tutorial. My custom taxonomies are displaying. But the problom is my list is not in proper hierarchy. Child list is not displaying as a child. All data is displaying in a single unordered list. Second thing i want to give class to my parent list like and child also. How it can be possible.

  7. Aniket says:

    i would like to add selected taxonomies on my sidebar. I have installed the plugin and it works fine. But i would like to know/learn, is there a way to add selected taxonomies using the code? Like there could be a exclude or include feature where in i could manually add the id’s of the taxonomy that i would want to display or not. Thanks.

  8. jas says:

    very helpful post but i am facing one problem with this,
    i am using Custom Taxonomies Menu Widget and able to show a custom taxonomy in sidebar but when i click on the category link of custom taxonomy than page shows that No posts found.

    is there any problem in archive page????

    please help.

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.