A taxonomy is an organization or classification of things by relationship. The taxonomy system in WordPress is largely untapped but has a lot of potential.
By default, WordPress comes loaded with three taxonomies: category, post_tag, and link_category. But, plugins and themes can extend this to create even more.
What I’ll be showing you in this tutorial is how to make a page template that displays each taxonomy on your site in a cloud format. You can only do this with WordPress 2.8+. Prior to 2.8, this was only possible with post tags.
Creating the page template
First, you should copy your theme’s page.php file. Save it as taxonomy-clouds.php. Near the top of it, you’ll see this line of code:
<?php get_header(); ?>
You’ll want to change that to:
<?php
/**
* Template Name: Taxonomy Clouds
*/
get_header(); ?>
If you need more information on this process, check out my tutorial on how to create page templates.
Adding the taxonomy clouds to your template
Farther down the file, you should see something that looks like this in the code:
<?php the_content(); ?>
Just below that, we’ll add our new code. What we’re actually doing is loading all of the available taxonomies and looping through them. During each loop, the wp_tag_cloud() template tag will display the cloud.
<?php global $wp_taxonomies; ?>
<?php if ( is_array( $wp_taxonomies ) ) : ?>
<?php foreach ( $wp_taxonomies as $tax ) : ?>
<h2 class="taxonomy-label"><?php echo $tax->label; ?></h2>
<p class="taxonomy-cloud">
<?php wp_tag_cloud( array( 'taxonomy' => $tax->name, 'number' => 0 ) ); ?>
</p><!-- .taxonomy-cloud -->
<?php endforeach; ?>
<?php endif; ?>
Mixing two untapped features of WordPress
I’ve previously called page templates the untapped potential of WordPress, and the same definitely goes for taxonomies. What I hope to continue doing with this series is broadening our view of what WordPress can do and get people kick-started in thinking of unique ways of extending the platform.
Have a little fun with your new page template. Try out some different parameters with the wp_tag_cloud() function. See what you can come up with.
This tutorial is for WordPress version 2.8+.



A tutorial for WordPress 2.8, before it’s even out? Justin, you are one on-the-ball blogger! Thanks for sharing your know-how. I don’t know whether I’ll get all fancy with these cool taxonomy clouds, but I’m excited about custom taxonomies. WordPress just keeps getting better!
Jessi Hance — Actually, this is my second one. I covered tag descriptions in the previous tutorial. I think I might have a few more up my sleeve though.
I’m not sure if I’ll use the taxonomy clouds either, but it’s kind of a neat concept. The coolest thing is that we can use any taxonomy with the
wp_tag_cloud()function now.[...] Creating a page template that lists all of your WordPress taxonomies (tags: WordPress tutorial) Leave a Reply Click here to cancel reply. [...]
Eventually the built in tag system for WordPress might have all the features available within Ultimate Tag Warrior
Andy Beard — I never used UTW, but I remember a lot of people loving it.
i read every single of your post sometimes i read it over and over again ..you really inspired many people here..wish you a good luck in everything you do..
Hi justin, great tutorial on the taxonomy posibilities.
I do have 1 question.
I went on and used yoast´s plugin to start with, because i wasnt sure on how to get the taxonomies displayed, but i can see that im gonna try out the tutorial you made for the movie database – i guess it would work great for recipes aswell.
Is it possible to show ONLY the taxonomy used, instead of all the taxonomies?
Look at http://www.kokkekniven.com/opskrifter/
It shows both blogroll, categories and tags – and im not sure on how to proceed on this issue.
Also – im using 4 taxonomies – Season, origin, type of meal and ingredients will be coming. How would i manage to make 4 templates, showing only 1 taxonomy on each page?
Hope you can help.
Best regards and thanks for great tutorials,
Kristian
Kristian — I don’t even recommend a plugin for creating taxonomies. It’s literally a few lines of code, and you get more control by doing it yourself (not to knock Joost’s plugin though, which is cool).
Instead of adding all that code I added below
the_content()(from the code in the post), just add one line:Of course, change
taxonomy_nameto the name of your taxonomy.Justin – I actually deleted the plugin and followed your tutorial to the point, and i guess i have done all the right things, except the code above and its working great.
Thank you so much for the help.
Justin – i came to think of something you might know of!
On my site im using 4 taxonomies:
Season, ingredients, origin and type of meal.
Know im planning on making a “wikipedia” of fruits and vegestables?
What would be best for me and the users?
Using the existing ingredients tags, or make some new under the taxonomies fruits and vegestables?
Do you know what I mean?
Question number 2:
Is there a way in options theme, that i could use the tabs function to display recipes?
tab1: Recipe by origin, tab2: recipe by ingredients, or something like that using the taxonomy?
Hi Justin,
Would it be possible to use these as navigation? For example, genre is the parent, which would be in the navigation bar, and as a drop down menu would be the different genres?
Or can this not be done at this point?
I just wanted to let you know that i enjoy reading you blog, hmm that sounds like a spam entry but especially the taxonomies have so much potential that probably a fork of wordpress itself could be based on it.
it has the potential to integrate a lot with a lot especially when objects (code) are linked to taxonomy terms.
i was thinking myself of creating a crm system based on physical .vcf cards (there are some open source libs) using these concepts right around wordpress. “contact”, “household”, “address” etc…
while im typing… what I was thinking is that taxonomies are related or more or less the same within a specific domain as requirement types / traceability types. If you spend some time with e.g. Rational RequisitePro you see a pyramid unfold itself of requirement types. E.g. software teams start out with lists of “requirements” but only after a while start to categorize them in TYPES e.g. non functional requirements / use cases / release / actor and so on… and they all are related to each other. The funny thing is that those requirement types as an instance “a requirement” are then again coupled to other systems like a workflow system so that a specific requirement is then linked to a Request like a defect. which is again a type. traceability is then important here: you could find the chain up by constantly asking why, why, why. e.g “movie” : why do i buy the movie. “because i have hobby movies”. why do i have hobby movies. because i want to have fun etc… you could organize an otherwise chaotic household in some more structure by starting out letting them have “tags” (like a software team which simply has “requirement”) and slowly improve a household by organizing these tags in types. The next step is to link these things to other systems e.g “contact” is automatically coupled to a household crm system and “todo” to a todo application. Instantly. It would improve households. They can start out with simply a “blog” and the more content is going in there the more the need will rise to organize it thus improving it.
Justin is there way to show taxonomy as list instead of wp_tag_cloud?
Hi, thanks for all your great Wordpress guides.
I’ve been reading your guides about Taxonomies quite a few times now.
I have a movie site and i want taxonomies for Actors, Directors and Studio.
This works fine so far, i can even get all actors to show using the tag_cloud.
My biggest problem is that all my taxonomies (when clicked) end in 404 Not Found.
Do i need to make some kind of template for the taxonomy ? or do i have to make a template for each term inside the taxonomy ? That would be a lot of templates if i had to do that for each actor.
Can you please point me in the right direction.. i want to show all movies with that actor if the actors name is clicked.
I’ve read all of your guides but still have not found the solution for this, so i guess there must be something i missed somewhere.
Cheers,
Knat Simon
Good tip. I replace my plugin with your script. Very easy. Now i have only 24 Plugins.
Thanks for the tutorial!
I’m still trying to figure out how to make the taxonomy page show up. Could you give me any tips? Like if I had /actor/tom-hanks, I know how to do that. But what if I want a page called /actors that lists all actors?
Sorry, I retract my question. I should have read this more carefully: http://justintadlock.com/archives/2009/03/13/page-templates-the-untapped-potential-of-wordpress
I’m not really good at following instructions. For other ADD people like myself, it’s just a page that you need to create, and assign that to a template taxonomy-actors.php or something. Then in that template you can do whatever you want with a Loop, static text, clouds, other tomfoolery, etc.
If I create an /actors page, and I have /actor/tom-hanks… would it be useful to have an /actor (singular) page as well and that points to the same template? That way I could avoid some 404s. Or I guess it could be a rewrite rule to permanently force the /actors URL.