Micro Themes
  • Home
  • Services
    • Front-End Coding
    • Back-End Coding
    • WordPress Development
    • Single Page Apps
  • Support
    • Subcription Plans
    • Support Forums
    • Changelogs
  • Reviews
  • Products
  • About
  • For Agencies
  • Order Now
  • Client Login
← Return to blog

How to create a list of custom taxonomies in WordPress

Nov 03, 2014 by Micro Themes in Tutorials

Expand Text
  • Share Article
  • Like This   15
  • Global Views   521

While developing our Quantum theme we came across a particular problem – how to display a drop list menu of a custom taxonomy. We required this functionality for our private members area, in particular a widget that we were developing to organize client files by year. At first we discovered the get_terms function, which is native to WordPress, but we were unable to populate our list due to the fact that the slugs in the taxonomy were not assigned to anything in particular – which makes total sense if you think about it…if slugs are not assigned to anything why display them? In our case we are using these slugs for filtering purposes so we needed to display them regardless of their relationship status.

It turns out that we were missing a crucial argument needed to retrieve slugs in their empty state (slugs are considered empty to WordPress when they are not assigned to anything) and here is the code to make it work:

$archiveDates = get_terms( 'archive_assignment', array( 'hide_empty' => 0 ) );

As you can see in the code we passed in the hide_empty argument and set its value to 0 (it can also be set to “false” if you prefer). And to further clarify the “archive_assignment” is the name of our custom taxonomy that we created for media file types.

And that’s all there is to it :]

Happy coding.

Tags: taxonomies, wordpress

  • How to filter users with
  • Why you should secure your

About the Author
Leo Nanfara

Leo is the owner of Micro Themes and has been a web developer since 2006. For the last 6 years Leo has been working extensively with WordPress developing custom themes, plug-ins, widgets, etc. for clients across Toronto. When Leo isn't writing code he's usually at the gym, engaging in sports, playing Fifa soccer on PS4 or playing with his nephews. Oh and he also loves coffee...usually with a cupcake.

      Search Articles
      Popular Tags
      coupon database discount facebook queries sale server optimization taxonomies wordpress
      Recent Articles
      • General tips for maintaining your WordPress website July 8, 2018
      • Github account is now live! July 5, 2018
      • All Micro Themes products now accessible with a monthly subscription! July 1, 2018
Pro-Cast WordPress Theme
Quick Links
  • Home
  • Services
  • Products
  • About
  • For Agencies
  • How it Works
  • Blog
  • FAQ's
  • Our Policies
  • Sitemap
  • Subscriptions
  • Forums
  • Changelogs
  • Themeforest
Services
  • Front-end Coding
  • Back-end Coding
  • WordPress Development
  • Single Page Web Apps
Get in Touch
  • Order now
  • Get a Quote
  • Contact Us
info@microthemes.ca
+1 (416) 859-6468
Micro Themes
  • Let's Tweet
  • Follow Us
  • Need Help?
  • Free Files : o

© Copyright 2013-2018 MicroThemes.ca

WC3 and WCAG validated

Designed for Firefox, Chrome & Edge