Lately, I’ve been writing a lot about how to create custom taxonomies in WordPress. I still get questions every day about practical applications with them.
Usually, I’m asked, “I understand the definition of taxonomy, but what do I do with them?” This is what I will attempt to answer in this post.
At the end of last week, I managed to talk my cousin into helping me set up a movie database. I thought this would be a great testing ground for custom taxonomies and allow me to present an example of how they can be used.
Go ahead and take a spin around the database and see what we’ve put together. I think it’s a neat concept.
You should make note that some of the things explained in this tutorial assume that you’re running WordPress 2.8+.
If something in the design is a bit wonky, pay it no attention. I just quickly merged it with the main site design and it could use some work.
The custom taxonomies
I created six new taxonomies for my WordPress install: actor, director, genre, producer, studio, and writer. These taxonomies allow readers to find movies based on certain criteria. For example, you can view movies that Tom Hanks has starred in.
The idea here is to give readers the ability to navigate around your site. You want organized content. You want content that’s linked together in meaningful ways. Custom taxonomies allow us to group our content in ways that simple categories and tags can’t.
Creating the custom taxonomies
I recently covered how you can easily create taxonomies in WordPress 2.8. To understand the mechanics behind creating and using them, read that post.
To do this, I added this code to my theme’s functions.php file:
<?php
add_action( 'init', 'create_pc_db_taxonomies', 0 );
function create_pc_db_taxonomies() {
register_taxonomy( 'actor', 'post', array( 'hierarchical' => false, 'label' => __('Actors', 'series'), 'query_var' => 'actor', 'rewrite' => array( 'slug' => 'actors' ) ) );
register_taxonomy( 'director', 'post', array( 'hierarchical' => false, 'label' => __('Directors', 'series'), 'query_var' => 'director', 'rewrite' => array( 'slug' => 'directors' ) ) );
register_taxonomy( 'genre', 'post', array( 'hierarchical' => false, 'label' => __('Genres', 'series'), 'query_var' => 'genre', 'rewrite' => array( 'slug' => 'genres' ) ) );
register_taxonomy( 'producer', 'post', array( 'hierarchical' => false, 'label' => __('Producers', 'series'), 'query_var' => 'producer', 'rewrite' => array( 'slug' => 'producers' ) ) );
register_taxonomy( 'studio', 'post', array( 'hierarchical' => false, 'label' => __('Studios', 'series'), 'query_var' => 'studio', 'rewrite' => array( 'slug' => 'studios' ) ) );
register_taxonomy( 'writer', 'post', array( 'hierarchical' => false, 'label' => __('Writers', 'series'), 'query_var' => 'writer', 'rewrite' => array( 'slug' => 'writers' ) ) );
}
?>
Creating term clouds with custom taxonomies
If you take a look around the movie database, you’ll notice I’ve made ample use of term (tag) clouds. Each represents a different taxonomy and will help you find movies in different ways.

A term cloud of movie genres
Built into version 0.6 of the Hybrid theme (will be released after WordPress 2.8) is a widget called Tags. Traditionally, this widget would allow you to show a tag cloud. In the new version, there’s a select box to choose a taxonomy, which allows us to create a term cloud based on any custom taxonomy. Pretty cool, right?
If you’re not fortunate enough to be using the Hybrid theme, you can hardcode a term cloud like so:
<?php wp_tag_cloud( array( 'taxonomy' => 'taxonomy_name' ) ); ?>
Displaying custom taxonomies in a post
Also covered in my previous tutorial was how to list taxonomy terms for a post. Simply replacing taxonomy_name in the below code with the unique name of your taxonomy will handle that.
<?php echo get_the_term_list( $post->ID, 'taxonomy_name', 'Taxonomy Label: ', ', ', '' ); ?>?
Here’s a look at the movie page (single post view) of Turner & Hooch:
Notice how each taxonomy’s terms are listed. It gives you a view of the actors, genres, directors, producers, studios, and writers for the individual movie.
Displaying taxonomy terms in a page
When dealing with the vast amount of movies available, there’s no good way to show off everything in a sidebar and other small areas. I needed a way to show off each taxonomy on a separate page. So, I created six page templates to handle this:
In each template, I used the wp_tag_cloud() function (shown above) to show off a particular taxonomy. If you’re unfamiliar with creating page templates, read this tutorial on how to create your own.
Taxonomy term templates
Taxonomy terms get their own templates just like tags, categories, and other archives. In keeping with the Tom Hanks scenario, we’ll take a look at the Tom Hanks archive.
There are several things we have to do to make this happen. First, one useful bit of code I appended to my theme’s functions.php file allows me to add any XHTML to my term descriptions:
remove_filter( 'pre_term_description', 'wp_filter_kses' );
Once that was done, I found Tom Hanks under my Actors taxonomy in my WordPress admin (a sub-menu of Posts). I then added an image and short description of the actor. This shows up at the top of the Tom Hanks archive:
Not all themes’ archives are equipped to handle this. Instead of hacking up your theme’s archive.php template, copy and rename it to taxonomy.php. You’ll want to add these two code snippets to this file, replacing other code that might be in the way. Theme authors: You should take note of this.
To get the proper name of the taxonomy term (usually the archive page title), use this code:
<?php $term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) ); echo $term->name; ?>
To show the taxonomy term description, use this code:
<?php echo term_description( '', get_query_var( 'taxonomy' ) ); ?>
Try creating custom taxonomies for yourself
I hope this helps explain how taxonomies can be used on a site. I wanted to give everyone a real-world example to better understand the concept.
I didn’t go into complete detail on each bit of code because the post was getting much too long. In order to better understand how the code works, read over my tutorial on creating custom taxonomies. There’s a lot of great information in that post.
As always, feel free to ask questions and discuss. I’ll be happy to help out. Heck, go rate a few movies on the movie database. It could be fun!


![Tom Hanks taxonomy archive View of the Tom Hanks [actor] archive](http://justintadlock.com/blog/wp-content/uploads/2009/06/tom-hanks-archive.jpg)
This is honestly one of the most awesomest posts I’ve read about this tricky feature that is taxonomies, since they were introduced in WP. Very practical, very simple. Great read!
I REALLY want to understand taxonomies, but just can’t. Why wouldn’t you use tags?
I’m sure this happened when tags came out, many people must have thought, “why not use categories?”
Couldn’t agree with Ozh anymore. Makes me wonder if custom taxonomies are what I need to create a family tree (design) in WordPress. Thanks!
This is going to help me a lot with gigography and lyrics on a website I run. I hope it does not use up too many queries. Thank you.
This is pretty flippin’ sweet..
OOOO! Do the same, but make it authors and books. *drools*
great post, as usual !
This is wonderful! It’s one thing to understand taxonomies but it is SO awesome to see them put to a practical use.
Ozh — Thanks. It’s definitely hard to explain sometimes, but it can be useful.
rgregory — You could use tags to replicate only one taxonomy here. Instead of tags, you could change the name of tags to actors. That’s fine when you only need the one taxonomy. In this post, I needed six different taxonomies for my posts: actors, directors, genres, producers, studios, and writers. There’s just no way to really replicate that with normal tags in the same way.
Remkus — Custom taxonomies might come in handy building a family tree. I suppose it comes down to how you want to structure the site.
Iva — I’d like to see how your site works when you implement this feature. I can think of some useful things for that type of site.
As far as queries are concerned, you’ll be fine. The taxonomy functions are the same thing used by the tag and category functions in WordPress.
Andrea_R — I’m having loads of fun with it. I’m excited about seeing others take these basic ideas and building something even cooler.
amalik — Thanks. Glad you enjoyed it.
Kim Woodbridge — Well, I guess I’ve accomplished my goal then.
I figured the best way to do it would be to lead by example.
Justin: Thank you. Now I’m intrigued, what would useful things be? The site itself is a crossover between a fansite (I find the term fansite offensive, because fansites are usually designed by people who don’t know coding, design in obsolete ways and steal everything they possibly could) and a news blog; and it never utilised categories and tags for anything other than news, everything else resides on pages; but I often end up interlinking those pages the old-fashioned way.
I’m basically waiting for WP 2.8 to start developing the site’s next version (ever since I’ve seen the original tutorial on taxonomies) because of taxonomies AND clearning my documents’ head from unnecessary things some plugins appear to be generating and I’m always open to beta-testing interesting things once it’s happened. The lack of custom custonomies was the reason I never opened the gigography section to public and the reason two other sections are half-a$%ed.
I guess I’ll jump to the forum.
Custom taxonomies not “custonomies”.
Justin this is a fantastic post. I can see a bunch of uses of this great feature. And I must agree with Andrea_R that this would be cool with a book-site. But why stop there, any kind of shop/review site could have great use of this. But what about a food- or estate-site? If only one could choose to cross-reference different taxonomies.
I have asparagus and potatoes in the fridge, what can I make? Or
I would love a office in Copenhagen for about X $
Anyway, love the tutorial, can’t wait for WordPress 2.8…
Justin, this is exactly what I’ve been trying to figure out for the past couple of days.
Thanks so much!
This will be extremely useful for a site I’m building for a large band with a large discography.
Hey Amy,
I’m trying to build a discography and was wondering if you had any success? Mind sharing the basics of how you set it up?
YOU are a Ninja. I’ve just started using taxonomies for a real-estate theme/plugin that describe properties in a separate sidetable (not posts or pages) — love the flexibility of the WP taxonomy API!
Justin, thanks for this. Ever since taxonomies were introduced in 2.3, I’ve been waiting for someone to talk about them technically and give an excellent example of how they might be used in a real-world scenario.
Also of interest might be the Custom Taxonomies plugin, which lets you create/manage taxonomies without writing code.
Ahh, now I see that 2.8 will be bringing a lot of the advantages of that plugin into the core, which is great.
Such a great tutorial, help me understand taxonomies more!
Iva — Hey, you just coined a new word — custonomies!
The ideas I had were along the same lines that I’ve done with the movie database. You could use singers/artists/bands, record companies, song writers, genres, and probably other taxonomies. This way, you’d be able to easily link to something like all of Hank Williams’ songs. This would help keep users on your site for longer periods of time just browsing around. It’s a great way to organize and link massive amounts of information.
Thomas Clausen — I’d like to just organize my book collection like this. It’d be pretty cool.
I’m sure there’s a way to cross-reference between the taxonomies. I just haven’t figured it out yet. If there isn’t, I think there’ll be a demand for it once people start using this more.
amy gail — I’d love to see what you do with that. Let me know when you get it up and running.
Jason — Awesome! That sounds like a cool theme/plugin combo.
Matt Wiebe — It’s great that this stuff is moving to core. A couple of lines of code is all it takes. This puts the power in the hands of the end users to create taxonomies that are site-specific.
The Frosty — I’m glad I could be of help.
Hey Justin,
your suggestion with bands and music is exactly what I search for.
I know how to create my own taxanomies and how I can show them.
If want to list all CDs of a band (band taxanomy) how does it work, when I read one CD review and click on the band (thats the taxanomy) the the new page shows the band name and displays a image, title of all the available CD reviews.
this is what I dont find out yet.
Like in your movie database, it shows only the images.
Can you please explain how you created the templage-page for showing the diffrent taxanomies.
Thanks a lot,
Denis
Ok… just one question… is there somethings about Wordpress that you DON’T know?
Thank you for explaining this in such detail. I think I have just the project to implement this technique.
This will surely prove to be a great tool in creating niche websites.
No more boring category/tag structures… This is really awesome!
Brilliant tutorial! Count me in as one of those who understands the term “taxonomy” but didn’t have a clue as to how to practically use it. This is exactly what I need for my collections database!
I’m so glad to have found this great tutorial!!
I do have a question Justin.
You talked about creating a taxonomy.php so tag.php won’t work with the custom taxonomies?
Thanks for the tutorial! I created a custom taxonomy of ‘technologies’ and a term of ‘php’ but when I enter a url of http://www.mysite.com/?technologies=php I get the wordpress 404 error (I also get it if I try http://www.mysite.com/technologies/php). I copied my ‘archive.php’ file, renamed it ‘taxonomy.php’ and included “‘query_var’ => true” when registering the taxonomy… Any ideas?
Cristi — I’m sure there is, but usually when I come across those things, I try to figure them out.
Dumitru Brinzan — Being able to break things down on websites in specific niches is what I’m really thinking about here. It helps the site become more unique and personalized.
Vix — What kind of collections database do you have? It’d be neat to see how you use this.
Sarah —
tag.phpshouldn’t work because a taxonomy is not a tag. But, a tags are a taxonomy (though I don’t think the opposite works with templates).Chris — Yep, that happens. Here’s a list of things to try:
1) Make sure you’re using the latest version of trunk.
2) Clear your cache and refresh your browser.
3) Go to your permalink settings and re-save them.
Great article Justin.
O`Reilly should really call you
Right, well that makes sense. Can’t wait to try it out in my next project
This would be perfect for organizing my anime&manga blog. There are so many genres that one series can fall into so it gets hard to figure out how to tag it. This would make things a lot easier!
Justin, thanks for the detailed posts on taxonomies. Wonderful to have it all digested like this.
Just recently I’ve come across the Pod plugin that provides a framework for creating custom content types and relationships between them.
I know that this is different to custom taxonomies. Seeing that you have aquainted yourself with WP 2.8 already, my question is (if you are familiar with the concept of the Pod plugin) whether WordPress 2.8 has any new features that would bring something like custom content types closer to the ‘core’ just like the custom taxonomies.
One of the most important things with content is the searcheability of said content so being able to create custom content types natively would mean the ability to use the native search functionality.
(Kudos to the guys that created the Pod plugin though, it seriously redefines what you can do with Wordpress.)
*/ just wanting to follow the comments */
John Myrstad — I’m patiently awaiting O’Reilly’s call.
EmmaBShireen — Yeah, a lot times, it’s all about things just making more sense. Custom taxonomies allow us to break from the rigid bonds of tags and categories.
Robert — It looks like custom content types will be getting better support in 2.9. It’s possible right now, but it’s just a lot of extra work.
Great post Justin. This is very valuable information and perfectly timed. Cheers.
Can you advise a plugin or other, that would allow for advanced searching of custom taxonomies? For example, from your example above, produce a result of all the movies starring Tom Hanks and Brad Pitt that were directed by Ron Howard.
Very neat explanation, I wish I could find one earlier
By the way, but what would you do if you want an actor or a director to have it’s own page, with more then just a photo and rich text description? Let’s say you want it to be as rich as your ordinary page, with user comments on it maybe, etc? Hmm… that’s an idea by the way, to add rich text editor to taxonomy description textarea!.. But what should one do with comments? Any straightforward way to bind them on taxonomy template?
These plugins implement custom taxonomies in more intuitive way:
http://yoast.com/wordpress/simple-taxonomies/
http://wordpress.org/extend/plugins/custom-taxonomies/
Brilliant explanation and marvelous patience and steadfast diligence in answering the comments! Thank you! I’ll be exploring your theme framework.
Paul — No one’s really been doing a lot of stuff with taxonomies, so you probably won’t be able to find that kind of plugin. It’ll be something you’ll have to get someone to custom code.
Dave — As far as I know, comments are only reserved for content/post types in WordPress.
As far as plugins go right now, I don’t see anything I’d add, especially when I can create a custom taxonomy in 4 lines of code. More intuitive? Not in the least.
Niraj — You’re welcome! I’m glad you enjoyed the tutorial.
Great post Justin!
Your ideas and tutorials fit perfectly with what I’m trying to do at my site, but it expands the posibilities.
Until now, I was creating a animation movies database similar to the one you’ve created. I made it based on pages and custom fields. You can see it here: http://www.protoones.com/film
Now, I will replace custom fields with taxonomies for sure!!!
Still, I have one question: I have created child pages with videos (trailers, clips, featurettes, …) for each movie. How would you create this “child pages” in your movie database?
I’m not sure that a video should be a taxonomy. An actor or a director may appear in differente moviesm then we use taxonomies. But a video only belongs to one movie. Right? So, what we should use for videos?
What do you think?
Thanks!
Argh. I have a ton of wordpress ‘tags’ in use with the format :, essentially. This would be a perfect way to fix those, but. There’s no easy way to move tags between taxonomies. Bleah.
SQL time!
Hey, I have a custom taxonomy called people, but the code that you wrote to get the proper name of the taxonomy term doesn’t show up the title on my archive page (taxonomy.php) for people. Any ideas?
Dani — I like what you’re doing with the database. Eventually, we’re going to move toward adding more information on ours.
If you upload (attach) videos/images/music they get their own “child” page of that particular post. These are called attachments in WordPress. Take a look at the image and file attachments page in the Codex. That would be the best option for posts.
Ipstenu — This sounds like a good idea for a plugin.
Paul — Sorry about that. I updated the post. It should be:
“It’s beginning to look a lot like Drupal
Links make vistors engauge
But the prettiest sight to see is the taxonomy that will be
On your own front page.”
But seriously this seems like 1/2 of the solution the other half being custom post types. That said, where did you add your ” image and short description of the (Tom Hanks)?” Seems like an “Actor” custom post type would be the perfect solution, no?
Is there a way to sort theses in alphabetical order by taxonomy?
I am looking for my post page to be in alpabettical order by a tag and it seems impossible.
Will this work? and if so how. Lastly, What kind of stress does this put on the database have so many terms to process, if any at all?
Thanks and this looks awesome.
Justin,
I will take a look at the attachments solutions you mention. Even though I don’t think it will work for my website because most of the videos are not uploaded, they’re just embeded from YouTube, Vimeo, …
On the other hand, I’ve been looking at your database and I have few more questions.
What kind of object are your movies? Posts? Pages?
If they are pages, I imagine you’ve created your own custom panels to add taxonomies to pages… Then, can you write another tutorial on how to do it? Or, even better, can you create a plugin “Taxonomy for ages”?
Lastly, for me, movies should be a taxonomy because if I write a post in the blog I should be able to tag movies, directors and studios in the same way using taxonomies. But if I made movies as taxonomies, I can not add actors and directors to movies, right?
So, in your popcritics web, how will you link posts in the blog section with movies in the database?
Thanks a lot!
Justin, I just found your post via WP Topics and I’m interested in exploring this technique for my site, and indeed some future projects.
A little while ago I was looking at how tags could be grouped and this seems to be the solution but I’m a little unclear as to whether using this techniques means negates the use of categories?
For example, I use categories exclusively for geographic information e.g. Continent > Country
I then use tags to describe the posts in terms of style of tents (e.g. yurts, tipis); activities (e.g. fishing, kayaking etc); setting (e.g. coastal, mountains, lakes etc) and so on…
The problem is these are all lumped together whereas it would be better if they were grouped.
If I use custom taxonomies, as you’ve described in your post, will I still be able to use categories for the geographical aspects?
Using categories in this way on my site offers me the ability to easily manage them in the admin plus other advantages, also there’s the hierarchical aspect as later I’ll want to drill down to regions within countries as the site grows.
@Dani asked ‘What kind of object are your movies? Posts? Pages?’
I too am interested to know this but I am hoping they are categories
Hey Justin! Thanks a lot, it worked like a charm. Great post!
Mike Schinkel — It looks like we’ll start seeing better support for custom content types in 2.9, so the other half will be there. For the image and short description of Tom, take a look at that section in the post above. I described how I done that.
Larry — Yep. You’d do it just like you do tags:
Just change
actorto whatever you set yourquery_varto when you registered your taxonomy. And, it shouldn’t put any additional stress on your database.Dani — Since you didn’t upload your videos, it’ll be a lot tougher. You could always upload them as an HTML attachment, but it seems like it’d be more trouble than it’s worth.
Each movie is a post. Ideally, I’d create a custom content type (movie) for it, but I’m waiting for better support for this in WordPress 2.9.
They’re set up as two separate sites, but I’ll likely write a custom script to intertwine them somehow in the future.
Garrison — WordPress sets up three default taxonomies: categories, post tags, and link categories. These can be overwritten, but your categories will be safe if you create additional custom taxonomies. You can use them however you want.
Paul — Thanks for letting me know. I need to update this before releasing the next version of one of my themes.
Refining my question.
Is there a way to sort by a second term.
i.e. I have am able to get a list of “Actor Types” – Union, Non Union.
So i get a list of all the “Union” Actors(term).
Can I sort that list by a second term , Say “Last Name” in alphabetical order?
How would you do something like this? Is it Possible?
Thanks again,
Thank you Justin, much appreciated.
Apart from your PopCritics’ treatment of custom taxonomies, do you know of any other sites out there that are implementing this feature?
I can see this becoming more popular over time and at some point it would be neat to be able to filter and mix by taxonomies. A nice idea would be to create a search tags function much like on Delicious where you can select and unselect a selection of tags to sort results by.
I find most blogs badly structured and see people use categories for ‘featured’ content, always a bad idea.
can you share the css that you’ve applied with the movie database? is it possible to get the whole template of the movie database?
@Justin: Thanks for the reply however this is what I read and it’s still unclear what you did: “Once that was done, I found Tom Hanks under my Actors taxonomy in my WordPress admin (a sub-menu of Posts). I then added an image and short description of the actor. This shows up at the top of the Tom Hanks archive:”
To what did you add the image and short description?
Larry Scott — You’d have to write a custom select query to pull actors by last name. To WordPress, this doesn’t mean “last name.” It’s just an entry in a database.
Garrison — I imagine many of the people reading this post are starting to use custom taxonomies. The few that I knew before using their own taxonomies, were doing it for more behind-the-scenes things. I’m using a color taxonomy on the Theme Hybrid Showcase.
Praz — No and no. Sorry, but it’s a custom theme for that site.
Mike Schinkel — Here’s a better step-by-step explanation:
1) Go to your WordPress admin.
2) Under the Posts menu item, find the Actors sub-menu item and click on it.
3) While on the Actors page, click on Tom Hanks.
4) Add an image and description in the description box while on the Tom Hanks page.
Thanks again, Justin.
Your Theme Hybrid Showcase is a good example for me as it mixes various taxonomies such as categories (theme), custom taxonomy (color), tags (tags)
One thing I noticed is the URLs are not closed with a trailing slash. Is there a reason for that? I’ve been told it’s better to close URLs.
Also, if I hack back to: http://themehybrid.com/showcase/color/ I get a 404, but I was hoping to see a page with a list of colours. Note: this is the same problem if I hack back to: http://themehybrid.com/showcase/tags/
The breadcrumbs don’t mimic the URL, i.e. the label ‘color’ doesn’t precede the color.
I see on PopCritics that you have set up pages to handle the tag clouds for each custom taxonomy, e.g. http://popcritics.com/movies/genres/
But again, the breadcrumb system doesn’t contain a link to these custom taxonomy pages.
Can your breadcrumb system, or any other system, be correctly set up to contain links to these custom taxonomy pages?
What a fantastic example! And the possibilities of this are endless. Thanks for explaining it in a simple way!
Hi Justin,
Again, a nice article.
Is that a way to add extra fields to taxonomies besides name, slug and description,? Like, i would like to add a field like “image” or “ISBN” . What would be a good way to do that?
All the best,
Adriano
Hi Justin,
I was just trying my hands with your hybrid theme. How can I remove ‘by author_name and date’ from the excerpt(home.php) and single.php?
How do you apply css and html to the taxonomies.
Like to show the genres in bold and to make it in two lines (genres, new line, and all the tags)?
Garrison — It’s no better or worse to use URLs with/without a trailing slash.
As for backtracking through the URLs, that’s something I’m going to handle on the Theme Hybrid Showcase at some point.
The breadcrumbs have nothing to do with the custom taxonomies. That’s something separate, but it can be addressed easily enough, at least with my breadcrumb trail code. Most of this stuff is all custom, so a theme/plugin can’t know how to address it without WordPress doing it.
thegirlinthecafe — Endless possibilities sounds about right. That’s what makes all this so exciting.
Adriano Estevam — I imagine you could extend it if you wanted, but I’m not entirely sure. You’ll just have to dig deep into the core WordPress files to see what’s possible.
Praz — You’re at the wrong site. Go to the support forums at Theme Hybrid.
clau — Check out the W3Schools CSS and HTML tutorials. That’s the best place to learn that kind of stuff.
@Adriano Estevam
You can check out the Pod plugin I mentioned in my earlier comment here that provides a framework for creating custom content types and relationships between them. With that you will be able to create various custom content types with relationships and link them up similar to the custom taxonomies here.
This is just awesome:)
You have just explained it in simple terms and for anyone to understand. You have given a greta idea for a project of mine.
Hi Justin,
After you answered me that, in your database, movies are posts I thought it was not what fit my needs because I want to “tag” posts on the blog with the movies they talk about.
Also, you build the database in a different site and you can not easily link blog posts and movies.
So, for me, movies should be taxonomies. But, then, I can not “tag” movies with genre, actors, … right?
To solve this issue I’ve found a solution: I create a movie as a post and as a term at the same time. Both have the same slug/name. Then I modify the taxonomy template page to include content form the post and the term.
The code to include the post in the taxonomy looks like:
What do you think? Any ideas to improve this solution?
Thanks!
Hi – To use your movie database example, I’d like visitors to be able to view the Tom Hanks page, even if Tom Hanks is not in any movies. So it would show the term description as usual, but then a message saying ‘No movies for this actor’.
I can successfully generate a list of all actors (including ones who are not in any movies yet) using the function get_terms() with ‘hide_empty’ set to zero, but I get a 404 error if I try to visit a term page that has not been associated with any posts (an actor in no movies).
Do you know if there is any way round this?
@dani: Your approach sounds like a great way to combine posts and tags (I once did something similar in Drupal; not sure why I didn’t think of it for WP.)
BTW, your code wasn’t included in your comment on the web page but I did get it in my email notification of your comment. I’ll try adding it for you below but in case it doesn’t work here’s hoping that @Justin will fix it:
I was able to set up everything in my blog to use taxonomies, Im also doing a kind of movie database, they really help a lot.
But do you think they can slow down my site? because im feeling like they do.
George Serradinho — Cool. Let me know when your project is up and running. I’d love to see how you’ve used taxonomies.
Dani — Yeah, everyone’s set will be a bit different. You’ll just have to figure out what works best for your site.
When it comes to more complex things like what you’re doing, nothing will work out of the box, so to speak. With my database, I have some ideas about how I’d eventually link both sites, but that’s a project for the future.
Your code got a bit mangled. You’ll have to use character entities and put it between
<code></code>tags to post it in the comments here.ilovewp — It’s working for me, but I do see a major WordPress error with this that I need to report in Trac. It seems that
term_description()returns an error if the actor doesn’t have posts associated with him.I’ll see if we can push for a fix with this in WordPress 2.8.1.
Mike Schinkel — The code is getting garbled up by the comment editor. You’ll have to use character entities and put it between
<code></code>tags to post it in the comments here.clau — At the very most, it would slow your site down by a fraction of a millisecond, but that all depends on how/when/where you’re using them.
How did you get the breadcrumb functionality to work with the custom taxonomies?
Also, with respect to creating a separate taxonomy.php file, how do you get a taxonomy to use this file by default?
Narc — That’s a feature of the Hybrid theme and will soon be a feature of the Breadcrumb Trail plugin (once it’s updated).
For your second question: Taxonomies will automatically use the
taxonomy.phpfile.I went to WordCamp Chicago this month and Matt Mullenweg addressed the audience about what was going on with Wordpress. I was surprised he spent time talking “techie” and was intrigued by this taxonomy thing. He also told jokes and told the story of how Wordpress got started.
I’m happy to say, with Justin’s awesome Wordpress plugin, Series, I created my first set!
http://freshworkshops.com/series/google-apps/
Adria Richards — I’m happy to see you’re making use of a custom taxonomy on your site. It’ll be interesting to see how people to continue to use them and come up with creative ways to make their content more manageable.
thanks for your reply – it would be great if that gets fixed in 2.8.1
just out of interest, what do you have your permalinks set to? i see there is no date, category, etc, in the url before the movie name, so it’s very clean.
ilovewp — The permalinks are set at
/%postname%. Typically, I’d do a date-based structure, but that wasn’t the goal with the movie database.Hey Justin,
If a taxonomy term does not have any content yet, it seems that is going to another page, no the taxonomy.php. Is it going to the 404 not found page ??
Thanks.
François
Justin; great posts … I’ve been reading through and have had good luck using taxonomies.
Question though; can you either explain or show the code you used for the movie database, that allows you to pull the image from your posts (movie posters) and display all of them on to one page? Your explanation of how to add “Tom Hanks” information in the header area was alright, but there was no information about how to get all the images from separate posts into that archive/page.
Francois — It uses
taxonomy.php, but WordPress has some issues with terms that aren’t related to any posts yet.Brian — That’s outside the scope of this tutorial. But, I’ll tell you that it’s all handled by the Hybrid theme. I just built a simple child theme for it to handle the layout and color scheme.
Great post , it had really hepled me . Good job !
Because this post seems to be such an important resource for people making custom taxonomies, I thought I’d note here that I learned the filename format for template files for individual taxonomies (rather than a catch-all taxonomy.php template that affects director pages, actor pages, genre pages, etc.
It’s taxonomy-slug.php; so, to use this post as an example, if you wanted your director template to be different from your other custom taxonomy templates, you’d just create a file called taxonomy-directors.php.
Thanks Justin for this great post — of all the WordPress hacks I’ve learned, this is maybe the easiest to implement and also the most useful. It really stretches the boundaries of what WP is capable of.
Ditutu — Thanks. I’m glad you found it useful.
topdownjimmy — Yes, good point. I mentioned this in the comments on the last post, but I keep forgetting to make this information easier to find.
It’s not
taxonomy-slug.phpthough. The correct form istaxonomy-tax_name.php, which you’ve shown with your example.For everyone, you can break it down like this:
Justin, tell me – how were you able to add an image inside of your tag description? The above example is of Tom Hanks; his picture followed by “Tom Hanks is quite possibly…”
I’m left kind of scratching my head as to how you accomplished that.
Another great tutorial… Thanks Justin!
I’m using custom taxonomies for a site that has both a blog and a portfolio. There will be one category for text posts and one category for posts containing photos. I’d like to use custom taxonomies to classify the photo posts with additional data, and may occasionally have blog posts related to those classifications that would get tagged using the custom taxonomies as well. What I’m not sure of is how to do two things:
1. Query posts that are under both one category and one taxonomy term
2. Query posts that are under multiple taxonomy terms
Any help would be greatly appreciated as I haven’t seen any info on this yet. Thanks again.
I’m wondering, is it possible to intersect tags. For example if I am looking for movies that star Tom Hanks, AND are also action movies? Or Martin Scorsese films that are also Academy Award nominees (assuming the award nomination existed as a tag)?
Being able to narrow on multiple tags simultaneously seems like a bigger advantage than simply grouping tags into sets (“taxonomies”). To select a tag and then generate a tag cloud for all items (and only those items) with that tag would really be cool.
It’s unclear if that is possible, and if it is, whether this is part of it.
@Jamie: I think that’s a great idea and one I’d like to see also. On one of my sites I will use categories for countries and custom taxonomies for: type of accommodation, style of accommodation, suitable for, activities etc.
So, it would be great if my users, when viewing listings in Spain could drill down using the various taxononies e.g. villa, boutique, couples, swimming (as an example based on the array above)
Sort of like filtering as used on Delicious.com, with a similar interface i.e. you enter the tags and search and to remove them click the [x]
Wow, this is such a cool post. Thanks! Can I ask how did you get the info to make the DB. I run a Dance Studio and this post opened my mind up to creating a “DB” on Dance movies, Songs and Quotes which my viewers could use and love. I’m often referring them to various movies depicting a visual of dance…this could really be right up my alley. Do you think you could help?
~Ashton
hey justin,
you mind dropping a slight of knowledge bombing, on how you were able to query all posts that were under the taxonomy of “movie” via http://popcritics.com/movies/ ? big thanks!
Brian — Read the part above about “Taxonomy term templates.” It describes how to allow full HTML in your term descriptions.
ConradH — I don’t think you’ll be able to do that with the standard
query_posts()function. You might have to get a developer to write you a custom select query to pull posts like that.Jamie — Can one intersect tags? Yes. But, let’s not confuse tags with “terms.” All tags are terms, but not all terms are tags. As far as I know, there’s no built-in way to query posts in this fashion, but it’s possible.
Ashton — Honestly, I own most of the movies in the database, so we got a lot of information from there. Everything else came from around the Web. The information is all out there; just do a Google search.
vvvv — “Movie” is not a taxonomy I used. Pretty much everything dealing with taxonomies I done is in the above post. The link you gave is just the home page, using the standard loop, showing the typical home page posts.
Thanks for the response Justin… I can dig in and try to write some SQL to hit the wordpress database. This may be a dumb question from newbie at advanced wordpress coding but when you write a custom query like that what is the best way to display results and have useful URLs, not just for the initial result set but the links from each result to (in this case) a page displaying content with multiple specified tags? Curious for some direction and ideas. Thanks!
hey justin thanks for the response.
is it possible than that you’d be able to show us how to write a query that show’s a specific taxonomy and all its terms, including having the proper permalink structure?
i made a request over in WP support forums on a thread you commented, but it seems like alot more light is shed here. would be really appreciated.
for example, if you had a taxonomy called WORK, and you had terms such Design, Logotype, Artwork, Illustration, etc. It would be ideal I’d think to be able to show all the terms filed inside the taxonomy of WORK in many cases. Thanks again.
Cracking post, I can see so many ways to implement this on my sites. Many thanks for the instructions and detail.
Great overview on how to use custom taxonomies in a real-world setting.
My only issue is with duplicate content.
Let’s use the Tom Hanks example. If I “tag” Tom Hanks with the taxnomies of “Actor” and “Producer”, wouldn’t that be almost considered duplicate content?
eg. hxxp://example.com/actors/tom-hanks
hxxp://example.com/producers/tom-hanks
Wouldn’t it be better to have a “Tom Hanks” page/post (eg, hxxp://example.com/tom-hanks) where you use a custom page template to output the taxonomies he is associated with? Then use the canonical header tag to direct all the different “Tom Hanks” taxonomy pages to that page?
I know this might be considered redundant considering the basic usage of taxonomies, but just a thought I had.
I think I did anything that´s mentioned in this tutorial but for some reason I get an 404 error when clicking on a taxonomies term.
A bit more in detail: I display the different taxonomies below the single-post (such as tags). That works fine. When I click on a term I only see my 404 page. It seems as if the template “taxonomy.php” (a copy of my archive.php without the conditional stuff) can not be detected or is not working at all.
Is there any known issue in WP 2.8.3? Or what else could be a reason for this? Any ideas?
To solve the 404 error issue, the trick is to call $wp_rewrite->flush_rules(); after registering the new taxonomies.
Without doing this the rewrite rules won’t be updated, this means that if you are using pretty permalinks wordpress will never figure out that you are asking for a new taxonomy and will never work out what template to load – it always 404s.
The problem is that you can’t just call the flush_rules in your functions.php after you register the taxonomy, it should only be called _once_ after you first register it, and again only after you unregister it.
If you write a plugin its ok, as you can add this to the install and uninstall routine, but if you are taking advantage of 2.8′s improved taxonomy handling to do this in functions.php its not obvious how to include this sensibly – for testing I’ve just called it once, then commented it out and that works, but my theme is no longer portable.
Justin – how have you handled this issue?
Quick Correction – calling flush_rules in functions.php doesn’t work (you can still use it in a plugin), instead you can open the Permalink Settings page in admin, this triggers a flush_rules event.
Having done this my taxonomy templates now work as expected for urls like mydomain.com/actor/tomhanks ie you can now use taxonomy-actor-tomhanks.php, taxonomy-actor.php and taxonomy.php.
I still haven’t found a way to elegantly handle this in a theme however.
ConradH — Not really my area. I mainly just play with the WordPress toolbox. You might can get some help with it as the WordPress support forums though.
vvvvv — It’s easy to show all the terms of a taxonomy. See what I posted above about
wp_tag_cloud(). This can be used as a cloud or a list.Bethan Trinoble — You’re welcome. I’m glad you found it interesting.
Ray — I wouldn’t consider that duplicate content. Adding an entire extra page would be pointless to me.
Honestly, every time someone brings up duplicate content, I cringe at the conversation. There’ll always be some sort of duplication of the content if you use a WordPress blog and don’t block any of your archives. It has never created any problems for me, so I definitely won’t be worrying about it.
Michael Oeser and benz — If you run into an issue with getting 404s, all you need to do is go to Settings > Permalinks in your WordPress admin and save. That should update everything.
I’ve only run into this issue on one site though, and it doesn’t seem to be very common judging by the few people that have reported having this problem.
hey justin, thanks for the reply.
sorry, i’ve miswrote what i wanted to say.
(i think what im requesting for has been brought up in the WP support forums before)
it’s not that i want to show the actual terms… not in this case at least.
what i’m aiming for is to show the posts that part of a specific taxonomy…or even… a specific term of that taxonomy. so i’m wondering, how would you go about building a query to rack together i.e any posts filed under the taxonomy of “WORK.”
thanks again.
vvvvv – Here is a query for getting all posts in a specific taxonomy term (in this case the taxonomy is called “locations” and the term I’m getting posts under is in a variable called $location_name):
query( array( 'locations' => $location_name, 'showposts' => 5 ) );
?>
I don’t know of a way to display all posts using any term in the “locations” taxonomy other than using custom SQL:
SELECT *
FROM $wpdb->posts
LEFT JOIN $wpdb->term_relationships ON($wpdb->posts.ID = $wpdb->term_relationships.object_id)
LEFT JOIN $wpdb->term_taxonomy ON($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id)
WHERE $wpdb->posts.post_type = 'post'
AND $wpdb->posts.post_status = 'publish'
AND $wpdb->term_taxonomy.taxonomy = 'locations'
ORDER BY $wpdb->posts.post_date DESC
You’d then loop through the results and display. More info here: http://codex.wordpress.org/Displaying_Posts_Using_a_Custom_Select_Query
Justin – I didn’t explain myself very well. Let’s say I have a query that returns all posts that are in one category and have a specified taxonomy term (or custom SQL or anything else outside the scope of typical archive/category/taxonomy pages). Right now, I would make a custom page template to contain that query and then create a WP page and give it some appropriate name and select the template. Page displays at mysite.com/page_name. Is that the best way to handle that situation? What if the query is ad-hoc based on some variables and it doesn’t make sense to use one specifically named WP page to display results?
I just started reading the Custom Queries page in the Codex and may have answered my own question: http://codex.wordpress.org/Custom_Queries
Thanks Justin, updating the permalinkstructure solved the issue.
Hi. Mmmm so im doing a database like the movies you maked. Do you think there could be a way to make something like an advance search, so you could check like the genres you want and it will show, that were maked with taxonomies.
Any plugin or idea on how to do it? =)
Great post!
When exporting the WP posts it doesnt seem to export the taxonomies.
Meaning it would also be difficult to import them.
I want to import my csv file (csv 2 post) and include the taxonmies.
Does anyone have an idea on how to do so?
Thx
I can see this being very useful for some of my ongoing projects. Do you think it is possible to sort the resulting tags by number of clicks? Maybe increment them in the DB every time and use that to roll them up higher in the order they are shown? This is just one more step towards being able to use WP as a full blown content mgt system for all my needs. Thank you!
interesting stuff, im definitely gonna be using this on my site!
Justin, may I ask you to put your tip from http://justintadlock.com/archives/2009/06/04/using-custom-taxonomies-to-create-a-movie-database#comment-130638 (re-save the permalink settings) into the main text of your fantastic tutorial?
Thanks.
Justin,
Great work adn explanations.
I’ve added new taxomony for my site and I want to have a sort of a glossary and a page template to show it. How can I add such a thing with the taxonomy?
I was scouring the web for this. This is the first time on your site and I just spent like 8 minutes browsing and reading comments. You’re doing an awesome job it seems. I’m trying to get familar with wordpress also for CMS I want to use on my site.
I didn’t know it was called Taxonomies…good to know =D
I’d just implemented my own custom taxonomy, but couldn’t get the pretty permalinks working – but sorted now thanks to Justin and benz.
I double the tip on putting the settings -> permalinks trick in the main tutorial. I almost missed this, and I’d be lost without it.
Hey Justin could you please explain this line in greater detail?
You did some new stuff with the label and rewrite that I’m not totally understanding yet.
Do you have any ideas about how to add meta boxes to the term description page? Is it possible to use add_meta_box or should use a filter?
Someone on this thread was asking about making custom templates for taxonomies. Taxonomy.php will get you started, but what about when someone clicks on the permalink of a post using a custom taxonomy? Assuming you want to preserve some context, like the side bar of posts using custom taxonomies.
If you are in that position, this may help — I needed to create a custom single.php so that if a post is within a custom taxonomy it would show a different layout than a regular single post.
This solves it for me:
I put this code into single.php (clearing all other code out) then I created single-teaching.php and /single-default.php:
Basically, if the post has any tag from my “Album” custom taxonomy – then display that post using the file single-teaching.php otherwise if it does not have a tag from the ‘Album’ taxonomy applied, then display the post using single-default.php
In my case, I have posts that are blog posts, and posts that are “lessons.” The lessons are chunked up into major and minor categories and finally down into individual posts that either sell a pack of lessons. The packs of lessons needed a link to enable drilling down to see a list starting with the offer for the pack of lessons, followed by each individual lesson.
I’m using categories to create navigation through the lessons and for reasons too long to explain here, I found that creating this custom taxonomy called “Album” did the trick so that I could first display a feed of all the Albums belonging to a major or minor category, then provide that “View all albums in this series” link courtesy of the custom taxonomy “Album.” Clicking on the link shows each post having the same Album tag.
This could not be done with categories+sub-categories or at least not as I could see, because Wordpress always wants to list all the categories a post belongs to. Sure, you can limit that by saying just display a category ID, but this needs to scale such that I can’t go hard coding category numbers in all the time.
I didn’t want to use tags, because the lessons already have tags that describe the content of the lesson.
Then, I discovered this additional bonus! Custom Single.php if my post is an “Album” ! How good are custom tags?!
And another additional bonus I just realized while typing this. I can have lessons show up as parts of more than one album — allowing my client down the road to mix and match existing content just by assigning the same Album tag to any group of lessons.
Thanks Justin for getting me started down this road!
Hey Jason,
What web site did you implement this on?
The remove filter line :
remove_filter( ‘pre_term_description’, ‘wp_filter_kses’ );
seems to have stopped working since WP 2.9. Now the only html shown that is entered in taxonomy descriptions are links, photos, captions e.t.c. no longer work.
Do you know of a fix for this?
Sorry that was some confusing punctuation, I meant to say that only links work, while other html is now filtered out.
I fixed this myself if anyone else is having the same problem in 2.9…
Add :
remove_filter( ‘term_description’, ‘wp_kses_data’ );
to your functions.php
Justin, maybe you could add this to your article because as it stands the article doesn’t work for > 2.9
Justin,
Can you estimate the time you took to put the first version of the site with the taxonomy together, including the ramp-up/learning time.
I’m getting ready to embark on a very project (both inspired by and using this tutorial!) and I’m wondering what I’m getting myself into.
WP/PHP Fluency = strong
where exactly you put this code????
Justin,
do you have an idea how one could display the name of the role next to the listing of actors on the movie article? that would be super useful…
tnx.
Hi Justin !
Thanks to your tutorial, I’ve (quite) finaly done what I’ve ever wanted to do with WordPress (2.9): the most simple yet powerful CMS ever !
I’m just at the start of putting together a new web site for a friend of mine’s record company, Bones Brigade records and I’ve been searching for months how to achieve what I’ve done in a few hours thanks to your post !
I’ve posted the link for an example, even if the web site is not finished (at all!), the linked page is working and uses all of your stuff:
- the page by itself is a category.php, namely the “artists” category file.
- the “name” on the left is a list of the posts in this category (a post by artist),
- the “genre” and “country” are list of the terms in the corresponding taxonomies, each term linking to a taxonomy-genre.php or taxonomy-country.php file (both under construction at the time of writing that comment, but working)
- the “featured artist” area show a random post of the artists > featured sub-category
- the “all artists” area starts with a list of the terms of the “letter” taxonomy, linking to a taxonomy-letter.php template while the pictures after that are, as the “name” area on the left, a list of the posts in the category “artists”.
As of now, the only thing I haven’t been able to do is to redefine the query in order not to “select” artists by letter, name, genre or country, but to be able to choose a letter AND a country AND a genre to create a list of artists, i.e., but, all in all, this taxonomy thing just opened a whole Universe of new things to play with !
A little more explanations in how to use the wp-tag-cloud classes to create unordered lists rather than a cloud would have save me some time, though
So, I hope the example page would demonstrate the power of taxonomies and what can be created with WordPress and the reading of your post / its comments.
Many, many thanks for the good work !
Hope this comment would have been of interest.
Cheers from France!
Justin
I cant get an image to show in the taxonomy or tag description. I have added the line
to my functions.php but when i call or
I only get the text but not the image.
Any ideas????
Great post with valuable information. I have a small question.
Is it possible to check a page for a certain taxonomy entry and display some picture or text accordingly?
For instance, if the page has “Tom Hanks” as taxonomy entry, show his picture somewhere on the page.
Thanks !
Yeah, same problem here.
Thanks for this very useful tutorial, it helped me a lot setting up a ‘Studio’ taxonomy for my anime reviews.
Hi Justin,
I hope you can help me out here.
Firstly, how do you create or assign this ‘http://popcritics.com/movies/the-junction-boys’ url permalink structure when your ‘http://popcritics.com/2010/05/03/hannah-montana-ends’?
I’m trying to achieve or find a way to edit my permalinks for custom categories? Is this possible? I see from your popcritics.com, you’ve managed to do just that, where movies will start with ‘movies/movie-title’ and certain post will start with ‘year/month/date’ system…
For example below:
http://popcritics.com/movies/the-junction-boys – /%category/%postname%
http://popcritics.com/2010/05/03/hannah-montana-ends – /%year%/%monthnum%/%day%/%postname%/
Appreciate you can advice me on how to achieve the above? I’ve been posting the same question and googling around, it seems nobody has done this before or created a proper plugin for it…
Thanks,
yeeloon
I have been waiting for this ever since I read the Custom Post Type article a few weeks ago. Great info. Just today I was trying to figure out how to pull a title for my archive and your reply to Paul did the trick.
Great stuff on this site, Justin. Thanks a lot!
This is a very interesting post – thank you.
Just trying to get my head around how this could be useful for my site.
Is it possible to include these links WITHIN the post ie from the wordpress write panel?
Hi Justin. I am trying to build a movie database site. And I want movie posts, directors posts, actors posts, reviews posts…. And I want to relate them. Your solution is not serving me, because I have a lot metadata. Example: each director has directed films, writed films, related news and other more simple metadata: name, birth, image etc. Each movie has directors, writers, actors and more simple metadata: year, images, genders etc
Like:
http://cinemacomrapadura.com.br/personalidades/8834/dennis-hopper/
how can I do this?
I tried flutter (very useful for creating write panels for director, films… but dont do the essential: relate the data) and pods cms (relate the data… ok… but is very trick in many ways: impossible to integrate into my template, a pod is not a post and dont behave like one…)
Any Ideas? How to relate the data in a easy management way? Should I move to another cms (drupal)?
I am very distressed ! Please help me! Thanks in advance…
Hi Justin, any chance you could post the full code for your taxonomy.php page? I’m having real trouble it.
Thanks
I’m trying to create a discography which will have the albums with a short description on the main page. Then when the user clicks on the album cover, it leads them to that album’s page with all the info in a table with “song title”, “lyrics”, “play icon” which will be a link to iTunes, “price”, and a “buy” button which will also take them to iTunes. I want the lyrics links to maybe pop up in a small window. Would using the taxonomy method be good for this purpose?
Very interesting article! But I have a question.
Is it possible to show posts filtered by both taxonomies and categories?
I.e.
I have two categories: “News” and “Reviews”
I have a custom taxonomy called ‘actor’.
Can I show all the posts filled in the “News” category and “Tom Hanks” actor? Or all the news related to “Russel Crowe”? Or all the reviews related to “Tom Cruise”?
@Justin Tadlock hey man! thank you this’s a usefull post! i’ve 2 questions:
1) how about the db fill? i intend have you got a set of function to Mass Insert the info data (title, content, custom fields, taxonomies, tags) about movies on each post, to check if a tag or a custom taxonomy already exists, to create on if not exists, etc??? If yes..can you post or mail me it?
2) is there a way to use the taxonomies to define unique Genres and two main ‘categories’ Movies and Serial (that will have the same Genres), and then join them ?
sorry for my bad engl
Here’s the new code to make HTML work in descriptions. Add to functions.php:
Source: http://wordpress.org/support/topic/348400?replies=8
Old post but still a goody! I wonder if there is anyway to relate all these taxonomies i.e writer, director, actor etc to each person.
That way we could have a person taxonomy which groups and lists each movie they have been involved in and their job in it.
Great post Justin. I used some of your pointers here to show taxonomy terms. Not sure if theres much support in the thesis theme for custom taxonomies and post types yet so working in the dark a bit and your advise worked great for a few solutions. Just need to find a multiple input advanced search with support for custom taxonomies now. Thanks
I am having an issue with some custom taxonomies, I am using them for a dog breeder so i have the following, breeds, parents(of the litter), and sex of the puppy. I dont want the sex of the puppy shown in the admin menu, but i do want it available when creating a new dog(post). Any ideas? im guessing im gonna just have to make a custom panel?
Hi,
Thanks so much for this – this post and others have been really useful to me, and I now visit this blog all the time. Just one question: is there a way to insert custom taxonomy information into individual posts rather than having it in the loop? It is just that I want the option not to show it and want some control over where in a post I display it.
Many thanks!
I just added a custom post type for a movie post page and somehow fubared my site severely so now when I go to my main url its redirecting to a post page. I have no clue what i did and removing the code i added to functions.php is not fixing it. ( http://www.shootforthehead.com )
Hope somebody can aid me.
Hi,
nice thing these taxonomies. And the movie website looks cool. How is the overview with all the movies made? That would be cool for my site, too.
But now my question. On my site I want to create reviews for CDs, DVDs, Books and Concerts.
Now it makes sence not to put all the new created taxonomies in the new posts (blog, content).
For example, if I review a CD, I dont need, “Venue, City or Author”.
When I review a Book, I need “Author, Artist, Publisher”
Concerts I will need “Venue, City, Artist”
Now I thought, I creat 4 diffrent Custom Posts And say, if I choose the Books Post, then show me, Author, Artist and Publisher taxonomies.
An other thing is, do I still have to choose the Categorie that will be in my case REVIEW – Books or REVIEW – CDs?
Can I still use Tags?
Cheers
Denis
Is it me, or is there no default functionality built in to WordPress 3.0 to allow for searching of custom taxonomies? Not only is it not working on my site (searching for custom taxonomy terms via the default search box in WP), but i can’t find help for this anywhere. please advise.
Hello, we are having a problem with the links to the taxonomies. Everything is showing fine but when we click on a taxonomy, the taxnomy.php page does not get called, instead it goes to the index.php page. We’ve tried everything we found in the tutorials and have no idea why this would be.
Does anyone have a clue how to fix or check this?
Thanks.
Hi everyone,
I am working on a project where i have a similar situation. I have successfully managed to create the first and individual pages for each actor.
I have created a custom post type movies and have a page named page-movies.php which shows the list of all movies.
Similarly, I have created a taxonomy Actors and have a page actors.php where i have the list of all the actors and a page taxonomy-actors.php which shows the details for the individual actor.
I access my movies page by mysite.com/movies/ and it shows me the list of movies. When i click on a movie name it opens a page mysite.com/movies/movie-name/ with the description of the movie and the list of actors that acted in it. Whenever i click on any actor name the url is changed to mysite.com/actors/actor-name/ and the page shows the actors details and the list of movies that he has acted in.
Everything fine till here.
Now i have a page filmography.php which shows only the list of movies that the particular actor has acted in but the problem is i cannot make it to appenf to the url.
What i would like to do is the filmography.php page be rendered when i type mysite.com/actors/actor-name/filmography or mysite.com/actors/actor-name/?filmography.php. Currently when i type the above url directly i get the page not found error. Also if anyone can tell me how do i create a link for filmography.php on the actor details page so that when i click on that link i am directed to mysite.com/actors/actor-name/filmography or mysite.com/actors/actor-name/?filmography.php with the desired result.
Can anyone help.
I am a complete novice in php and i tried whatever is explained above but failed. May be i am missing out on soemthing.
Hoping for a quick response. ITS URGENT.
Thanks in advance.
friends, how can i change side of my taxonomies (genre, actors, director, writers) on the page, I always see taxonomies on the down of page i need change to top of page, help me plz
How i can change position of taxonomy, I allways see my text or image of post under taxonomies.
I want to be able to put images and write text on the right or left side from taxonomies
http://popcritics.com/movies/turner-and-hooch
HELP ME PLZ
Hi Justin — another great post in your series of informative articles about taxonomies. I’ve been custom field user for a while, especially with custom field template. This is an off beat question, and if ridiculous or not possible, tell me!
Can I assign a custom field value to a taxonomy term? Why? I have the custom template boxes set up and all the assigned variables. If I want to “convert” them to taxonomy terms, can I? If so how? I know Scribu has a plugin for this purpose but I need to do it in code in the process of making the page.
Thanks
Hi,
Good stuff!
I am trying to create a taxonomy for dates or numbers. These are dates of archaeological objects, so they’ll be something like 25,000 BC with margins of error such as +/- 500 years.
Is there any way to integrate this sort of data into the taxonomies you discuss?
cheers
Patrick
is there a way to echo the custom taxonomy slug? I need it for a jquery class identifier and just cant seem to get it.
Hi, congratulations for your post.
I have a question
how to make a layout to actor like your example in the Taxonomy term templates
Thanks,
João
Is there any tutorial which explains, how to build a simple review system in wordpress theme like leetpress theme. I am looking for this thing from many days, I’ll be really really thankful if anyone can point me to such tutorial or guide.
Thanks for this excellent post, Justin. It takes seeing a real example like you posted above to see the power of taxonomies. I’m just seeing now that I’m only scratching the surface.
Thank you so much for this post.
Is there a way to associate a custom taxonomy with users of the website, so that I can do this exact thing for original content? I’d like to be able to display the avatar and name of each person associated with the post. I’m essentially trying to create multiple “author” taxonomies, all with different names.
Sorry to double post – just wanted to add that as examples, this type of functionality exists on funnyordie.com and vimeo.com
Another thought! (sorry)
A way around this (seemingly overly-complex) methodology I posted above might be to just associate images with taxonomy terms and keep it like your example. HOWEVER, what do you do in the case of Daniel Petrie Jr. in your Turner & Hooch example? How do you make it so you can click on him in either taxonomy and get to the same Daniel Petrie Jr. archive that displays ALL his credits (not just his writing credits or just his producing credits)?
Thanks for this well written tutorial.
Here’s a question, is it possible to create a page that queries multiple taxonomies?
Using your example, say I wanted to find all the movies that were produced by Stephen Spielbierg IN the genre Fantasy.
So basically sort by multiple taxonomies.
Oh and it would also be good if those custom queries could go to a search engine friendly url, something like.
http://domain.com/producer/stephenspielbierg/genre/fantasy/
THANK YOU!!! I’ve trying to crack this DAYS!!
Many thanks, that was really easy and I had successfully created 6+ additional taxonomies for better classification of products.
Can you please tell me how you created that movie database main page template to show that all movies in a separate boxes? And how you accessed the database with that custom search basis (like those with Tom Hanks)?
I have been waiting for this ever since I read the Custom Post Type article a few weeks ago. Great info. Just today I was trying to figure out how to pull a title for my archive and your reply to Paul did the trick.
Hi I have used the taxonomy picker plugin to try to select the page templates I have created using custom fields, but it only picks the content that is in the page editor and not the content in the template. Question is this possible.
I have successfully created a couple of hierarchicle taxonomies, but I get 404 errors when I try to use them in tag clouds or menus.
Thanks for the post,
So I have written a piece of code (pasted here at the bottom) which grabs only the posts that have the term ‘vejer’ which is inside taxonomy ‘locations’ that I have created in my functions.php – I have a “stupid” questions though – How can I grab & put inside the loop ALL the terms inside ‘locations’ but not in any other taxonomy? I can’t manage to do that whatever I do !
Thanks
Amit
Thank you very much, I’ve been searching to display taxonomy in single.php
at last, got it