Innovative Uses of WordPress Post Types and Taxonomies

Innovative Uses of WordPress Post Types and Taxonomies

Tutorial Details
  • Topic: Wordpress
  • Difficulty: Intermediate
  • Estimated Completion Time: 30 minutes

With the release of WordPress 3.0, two great ways to better organize and display content were introduced: post types and taxonomies. These two advances improve WordPress’ role as an all-around content management system, and they continue to prove that WP is not just a blog platform. When 3.1 releases with post formats, it will be imperative that you understand how to use and implement post types and taxonomies.

Tutorial now on Wptuts+

What We’re Going to Cover

In this tutorial, I will talk you through the following:

  • Overview of post types and taxonomies in WordPress 3.0
  • How to integrate post types and taxonomies into your themes
  • Real-world examples of how to use post types and taxonomies in innovative ways within your projects

By the time you’ve completed these steps, I hope to fuel your projects by examining other awesome ways to integrate these organizational elements in WordPress.


A Quick Overview of WordPress Post Types

When you think of post types, the important word to remember is organization. The post type itself will not add really any functionality, but it allows us to better organize WordPress content and build admin dashboards that are more specific to the type of site that we are working with.

Here are some important things to remember when working with post types:

  • When you create a new post type, a new upper level nav element will appear the main left side admin menu. From there, all of the standard post and page editors are available.
  • The URL string for a new post type will be : http://yoursite.com/{post-type}/{title}/.
  • You can create post type archive pages just like you do with categories, and you can even create special template files by creating an archive-{post-type}.php file.

“In the same way that posts are shown on their own archive with archive.php, custom post types will use archive-{posttype}.php.”

For other info on integrating post types, querying post types, and overall functions, visit the codex here.


Integrating Post Types via Functions.php

Integrating post types is simply a matter of including the register_post_type function. Once you have included this in your functions.php file, your nav menu should go from something like this:

our original wordpress menu

to this:

our new wordpress menu with our post type

In order to create custom post types, open your template’s functions.php file in an editor, and place the following function within the file:


function create_post_type() {
	register_post_type( 'mysite_reviews',
		array(
			'labels' => array(
				'name' => __( 'Reviews' ),
				'singular_name' => __( 'Review' )
			),
		'public' => true,
        'menu_position' => 5,
        'rewrite' => array('slug' => 'reviews')
		)
	);
}

add_action( 'init', 'create_post_type' );

Broken down, this adds the function create_post_type, and registers the post type mysite_reviews,


add_action( 'init', 'create_post_type' );
function create_post_type() {
	register_post_type( 'mysite_reviews',

You may wonder why I’ve named the post_type mysite_reviews, and not just reviews. I made the name more conspicuous in order to make sure that my post type wouldn’t interfere with custom post type names from other plugins or themes.

Another friendly reminder, your custom post types must not exceed 20 characters, as that is limit of the database column.

Here is a summary of the important post type parameters I’ve set above:

  • labels – WordPress allows us to label everything from the post type’s name to the label for adding new posts. A complete list can be found here. In the above function, I labeled the name of the post type and its singular name.
  • public – If set to true
  • menu_position – I set this to 5, which will place the post type directly under “Posts”. The other placements are as follows: null (below Comments), 0 (below Media), 20 (below Pages), 60 (below first separator) and 100 (below second separator)
  • rewrite – So that our actual term “mysite_reviews” doesn’t get put in the URL, we set the slug to “reviews” which will be much better in the long run for our visitors, links, and SEO.

For More Information

A full list of parameter arguments for post types can be found here.


Displaying Post Types in WordPress Themes

Since WordPress post types are simply an extension of the existing classification system, displaying them in a theme is quite similar to what is already in place. There are currently three primary ways to display custom post types in your themes:

  • Post Query
  • Single Post Template
  • Archive Template

Displaying via Post Query

To display the new post type mysite_reviews, you will want to open up the template file that you would like to display it on (in my case, I usually create a custom home.php for templates), and enter the following code:

$args = array( 'post_type' => 'mysite_reviews', 'posts_per_page' => 10 );
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();
	the_title();
	echo '<div class="entry-content">';
	the_excerpt();
	echo '</div>';
endwhile;

This simply creates a new WordPress loop that will display the title and excerpt from the 10 most recent entries in the mysite_reviews post type.

Displaying via Single Post Template

Just as you can customize the way individual posts are displayed via a theme’s single.php file, you can customize the way your individual post type entries are displayed. The easiest way to do this is to create a duplicate of your theme’s single.php file and rename it to single-{posttypename}.php. From there, you can customize that file to your specs. Using the example from above, we would need a single post template named single-mysite_reviews.php.

Displaying by Archive Template

While this feature will not be available until WP 3.1 releases, post types can also be displayed archive-style by creating a file in your theme named archive-{posttypename}.php. So, if we were creating an archive for the post type, we would create an archive template named archive-mysite_reviews.php and place it within our template folder.

With custom post type templating, custom theme creators can more easily create subscription and membership sites by restricting the content on these specific posts and pages to specified user groups.


A Quick Overview of WP Taxonomies

I won’t go into too much detail here as Paul Kaiser has already written a great overview of taxonomies and the code that is involved to implement the function (see the tutorial here). The key word to remember when thinking about taxonomies is classification. They are similar to tags, but allow for deeper, more content-specific classification.

In truth, they are an extremely powerful way to group various items in all sorts of ways.

For example, say that I have use the Reviews post type from above. Because I will definitely want to classify that broad post type, I can create taxonomies like:

  • Movie Reviews
  • Book Reviews
  • Product Reviews

With custom taxonomies, I could even go deeper into classifying the above taxonomies. I could go into movie genres, book authors, and product markets. Again, together with post types, these greatly increase WordPress’ content management capabilities.


Integrating Taxonomies via Functions.php

Overall, taxonomies are pretty easy to implement in your functions.php file. Remember, you can go hierarchical with them or treat them like tags, so the more complex you want the greater the difficulty. Either way, here is a quick rundown of how to incorporate these into your theme.

Again, open up your functions.php file and insert the following code:


    function movie_taxonomy() {
       register_taxonomy(
        'movie_review',
        'mysite_reviews',
        array(
            'hierarchical' => true,
            'label' => 'Movie Review',
            'query_var' => true,
            'rewrite' => array('slug' => 'movie-reviews')
        )
    );
    }
    
    add_action( 'init', 'movie_taxonomy' );

To break this down, first we give the taxonomy a formal name (“movie_review”), and we place it under the post type “mysite_reviews”, which we created earlier.


function movie_taxonomy() {
   register_taxonomy(
	'movie_review',
	'mysite_reviews',
    

Then we pass these values:


	array(
            'hierarchical' => true,
            'label' => 'Movie Review',
            'query_var' => true,
            'rewrite' => array('slug' => 'movie-reviews')
        )

This supplies the following arguments:

  • hierarchical – When set to “true”, the taxonomy will act more like a category. There can be parent taxonomies and nested taxonomies allowing for greater depth of classification. When set to “false”, they act like just like tags.
  • label – As with the post types above, this is the label that the taxonomy will publicly recieve.
  • query_var – When set to “true” this taxonomy becomes a queryable element.
  • rewrite – This sets the URL rewrite. Now posts in this taxonomy will be displayed as http://mysite.com/movie-reviews/{post title}/.

The end result within our admin nav should look like this:

New WordPress taxonomy in admin dashboard navigation

Furthermore, we can dive into that interface and add more classification categories and structure. That interface looks similar to the category interface that you may already be familiar with.

Taxonomy user interface

From this interface, you can edit the slugs of the various categories within your taxonomy, create new categories, and determine parent and child categories.

For More Information

A full list of parameter arguments for taxonomies can be found here.


Displaying Taxonomies in WordPress Themes

There are currently three primary ways to display custom post types in your themes:

  • Taxonomy Cloud
  • Custom Taxonomy Query
  • Custom Taxonomy List

Taxonomy Cloud

Just as there are tag clouds, there are taxonomy clouds. To make it easy, both tags and clouds use the wp_tag_cloud function. In order to display an array of taxonomy categories in a cloud, we would use the following code:

 <?php 
        wp_tag_cloud( array( 'taxonomy' => 'taxonomy_name_1','taxonomy_name_2' ) ); 
?>

For more information about the function and its parameter arguments, visit the codex.

Custom Taxonomy Query

Taxonomies can also be included in custom queries just like we did with post types above. For example, to display content from the taxonomy movie_genre, we would need to insert the following code into our template file:

    $args = array(
	'tax_query' => array(
		'taxonomy' => 'movie_genre',
		'field' => 'slug',
        'terms' => 'comedy'
		)
);
query_posts( $args );
    

First, we use the argument tax_query so that we can pass parameters that will allow us to query by slug or terms and return more accurate query results. In this example, we displayed posts tagged as “comedy” within the custom taxonomy “movie_genre”. Once again, like we did with post types, we can limit the number of posts that this query returns.

Custom Taxonomy Lists

To display a comma-delineated list of posts by taxonomy, we simply need to put the following somewhere in the loop:

    
    	<?php the_terms( $post->ID, '{taxonomy name}', '{Displayed Title}: ', ', ', ' ' ); ?>

There are other display options for this list, and the parameters can be found here.


Using Post Types and Taxonomies in Your Next Project

Now that we have the nuts and bolts, I think “Why do I care about these things?” is a really fair question. The possibilities with post types and taxonomies, especially working with clients that are often too busy to manage the intricacies of a site, is endless. This, in my opinion, saves time over creating new admin functions and updating plugins, and opens doors to new possibilities with much less work (and coding) involved.

Below are some ideas that I had about how to integrate these into actual work:

1. Review Sites

First, a review site could benefit from the custom templating options listed above (single and archive)

Here are some more post types and taxonomies that you could implement on a review site:

  • Post Type - Movie Reviews
  • Taxonomies - Genre, Actor, Director
  • Post Type - Book Reviews
  • Taxonomies - Genre, Author, Publisher
  • Post Type - Product Reviews
  • Taxonomies - Product Category, Price

2. Real Estate Listing Sites

While there are some good templates for real estate listing sites, post types and taxonomies let creative people make custom templates that can easily be maintained by clients and webmasters alike. Here are just a few ideas to use in your next project:

  • Post Type - Listings
  • Taxonomies - Area, Agent, Price, Rooms
  • Post Type - Agents

3. Event Listings

One thing that WordPress really lacks (in my opinion) is a good event management system. Post types and taxonomies could easily take care of that by offering a system to classify monthly events by location, day, or any other system you can think of.

4. Subscription Sites

With the creation of a new post type and template, you could create a custom, premium category for your blog or website and integrate a payment gateway to create your very own membership site.

5. E-commerce

By creating a product post type and template, you could easily add and display products for sale on your site. In addition, taxonomies would allow for easy product organization.


Where Do We Go From Here?

I hope this tutorial has explained post types and taxonomies in WordPress 3.0, and why they are an extremely valuable resource to implement in your projects. I know that there are many advocates of plugins (and I am a plugin author myself), but I hope that I have made the case that implementing these things is a very simple task and one that will save time for both you and your client in the long run.

The list of ideas above is a small one at best, so I would love to hear how you have implemented them into your projects or maybe some other uses that I didn’t list.

Thank you so much for reading!

Note: Want to add some source code? Type <pre><code> before it and </code></pre> after it. Find out more
  • http://www.wistudios.com Bassaddicted

    Very Informative, Very nice will use this soon need to create an additional Tab for Review :)

    Thanks Alot

  • http://www.bransonwerner.com Branson Werner

    One of those topics I can never get enough of. Loved the examples.

    I’m currently creating a business directory using post types & taxonomies.

  • http://facebook.com/terrygfx Terry Campbell

    This is something i will definitely need for all my reviews and news’ across the network i’m having.

    Thanks a bunch.

  • http://www.lavalleecreative.com Stephen

    I love custom post types. They make it so much easier for clients to manage their own content by using intuitive naming and more directed data entry options. Good overview of the topic…..thanks.

    • Dennis

      +1 :)

  • http://www.daveredfern.com/ Dave Redfern

    Hello,

    Nice post but custom post types should never be written in the functions.php of the theme but should be plugins. If a theme is disabled or changed the custom post type will disappear in the current setup.

    In a similar way to html and css divides content and styling, themes and plugins should do the same.

    Dave.

    • http://vietsonnguyen.com Vietson

      It doesn’t matter if you’re using a plugin or not, once you change the theme the contents of the custom post type will disappear from the site unless the theme you’re changing to already have support for the specific custom post types.

      • gsdgs

        fafafa

        • http://themeforest.net/user/mladenjacket/portfolio?ref=mladenjacket mladenJacket

          FAFALA SI MI TI FALA TI

  • http://www.techbrij.com Brij

    Nice Post!!!
    I have been using custom post type feature in projects and tools section and waiting WordPress 3.1 Release for Archive Template.

  • http://www.jauhari.net/ Jauhari

    This is what we looking for. thanks for share… I will try it now

  • http://sirwan.me Sirwan

    I will be bookmarking this one for sure and think this is what’s changing WordPress and turning it into a CMS.

  • http://www.wpfunda.com wordpress services

    Awesome post..great work ,Thanks a Lots :)

    i was not much clear with before, confused with post types and taxonomies before. and finally learn well from above Article.

    Keep rocking ..!!

  • http://www.designpalatset.se Kenth Hagström

    This is one of the pieces that has been missing in my WP setup. But I agree with Dave Redfern that they should be plugins instead of inside the themes.

    Anyway, thank you for the nice article!

    • Alex

      I disagree, implementing in the IS the great power of custom posttypes.

      And besides; there are allready many plugins for this if you wish to use plugins

  • http://maxdegterev.name/ Max

    I`m sorry, but how is this article related to Javascript from null series? Otherwise nice article, thanks!

    • http://www.ssiddharth.com Siddharth

      Apologies, slight slip up there. :)

  • http://DGISEN.COM Keven Marin

    This is an extremely powerful feature when you know who to use it.
    I’ll definitely recommend this article to my friends. Thanks for this sone Adam.

  • http://webkohder.net Sara

    Yup, I’m using this stuff in a project right now, with post-generated gallery of reviewed items and lots of meta boxes in the back-end. I learned most of it from an earlier article published on this site.

    Echoing what a guy said further down, it’d be nice to have a tutorial explaining how to put this stuff into plugins.

  • http://www.jacorre.com Josh

    Great article. I have been looking forward to working with these new post types and taxonomies.

    Right now I use categories and tags and have a plugin that is able to know which tags go with which categories. My assumption is that if I switch to this new way of categorizing, that plugin will no longer function the way it’s intended.

  • http://robguilfoyle.com Rob Guilfoyle

    These types of wordpress posts are invaluable, MORE MORE MORE!!

  • http://www.bionicworks.com Thai Bui

    This is one of WP’s best additions. A great way to look at it is that it organizes a specific post type and is tied up in the admin for clients.

  • http://gunnerrific.com Will

    I understand the concepts of types and taxonomies, but I don’t understand the benefits. For example, what are the benefits of using post types and taxonomies with a review site, instead of using categories? Does it simply make the administration side easier since things are more separated? Or can you take advantage of post types in post templates, and in custom fields on the ‘add post’ page? I want to see what sort of leverage using post types can give a blog.

  • Carlos

    I like WordPress, but it takes some work to turn it into a CMS. Registering post types, taxonomies. I know it is PHP and that is awesome in it’s own right.

    Check out Umbraco. Have had a lot of luck and time savings with it. It is ASP.net based, but you really don’t even need to know ASP.net. I don’t. I just learned a bit of XSLT and I was on my way.
    Very versitile out of the box. Only thing is hosting isn’t as widespread as WordPress because of the needs for Windows stuff. But since it is a browser based CMS you can use it with a Mac. I have a cheaper PC to help with local development, but you can always use Bootcamp on a Mac. Windows is cheap enough

    Just an alternative. I am looking forward to seeing how WordPress will become more of a CMS without having to build a custom templates on top of the existing ones.

    Thanks for the post.

  • http://www.somnia-themes.com/ Timon

    Thanks, definitely going to use this in my upcoming theme! :-) Gotta love WordPress 3.0!

  • http://maxoffsky.com Max Surguy

    Awesome tutorial, many rocks overturned and insights explained ! Thank you so much for making this available =)

    One question though, you mention that it is possible to turn a WP site into membership website with custom types and restrict content to specific group of users. Could you please elaborate on that ?
    Thanks !

    • http://twodoorscreative.com Adam Murray
      Author

      Max,

      There are a few ways you could do that, but the first thing that comes to my mind is displaying your post type via the archive method listed above and adding the following code to the top of the archive file below you get_header() call:

      <? if(is_user_logged_in()) {

      and then the following right above your get_footer() call:

      } else {?><p>I am sorry, but you do not have permission to access this page.<p>

      That would restrict the archive page to users that are logged in. There are other methods and restrictions, but that is definitely a start in the right direction.

  • http://liquiduscreative.co Jay

    Great tutorial, I’ve just implemented it on property management site to provide greater control over the content. One question I have is how to get the slug of the category to work?
    Example: http://mysite.com/movie-reviews/{categorytitle}/{post title}/

  • http://wpplugis.plrprofitclub.net/ addicted to plugins

    Great info – I’m going to update now and try this out. Also nice tutorial by Paul, thanks for the link.

  • http://imperativedesign.net Paul

    I have a custom post type implemented on my website.

    When I go to the custom post page that im displaying the posts on I see the first few ok but when I click the back button to see older posts I get a 404 error. Anybody know why?

    Here is my code, permalink structure, and a link so you can see the problem:
    link: http://imperativedesign.net/category/tutorials/c_plus_plus

    Permalink: /%category%/%postname%

    register_post_type(‘tutorials’, array(
    ‘label’ => __(‘Tutorials’),
    ‘singular_label’ => __(‘Tutorial’),
    ‘add_new_item’ => __(‘Add New Tutorial’),
    ‘publicly_queryable’=>true,
    ‘new_item’ => __(‘New Tutorial’),
    ‘public’ => true,
    ‘show_ui’ => true,
    ‘capability_type’ => ‘post’,
    ‘hierarchical’ => true,
    ‘_builtin’ => false,
    ‘rewrite’ => false,
    ‘query_var’ => tutorial,
    ‘supports’ => array(‘title’, ‘editor’, ‘author’, ‘thumbnail’, ‘title’, ‘excerpt’, ‘custom-fields’,'comments’ ),
    ‘taxonomies’ => array(‘category’, ‘post_tag’)

    ));

    //adds custom columns to custom post edit screen
    add_action(“manage_posts_custom_column”, “tutorials_columns”);
    add_filter(“manage_edit-tutorial_columns”, “tutorials_columns”);

    function tutorials_columns($columns) {
    $columns = array(
    “cb” => “”,
    “title” => “Tutorial Title”,
    “description” => “Description”,
    “length” => “Est. Completion Time”,
    “technologies” => “Technologies used”,
    “comments” => ‘Comments’
    );
    return $columns;
    }

    function my_custom_columns($column) {
    global $post;
    if (“ID” == $column) echo $post->ID;
    elseif (“description” == $column) echo $post->post_content;
    elseif (“length” == $column) echo $post->length;
    elseif (“technologies” == $column) echo “Joel Spolsky”;
    }

    //adds the category and tags section
    add_action(‘init’, ‘demo_add_default_boxes’);

    function demo_add_default_boxes() {
    register_taxonomy_for_object_type(‘category’, ‘tutorials’);
    register_taxonomy_for_object_type(‘post_tag’, ‘tutorials’);
    }

    Thanks!

    ~Paul

    • http://twodoorscreative.com Adam Murray
      Author

      Hey Paul,

      I’m not sure it’s a post type issue. Your category drop-down says that you only have 3 posts in that category, so not displaying a page 2 would be normal in that case. Can you explain more about how you think your post type is factoring in?

      Thanks!

  • http://www.e11world.com e11world

    I think scripts/features like this should already be in WordPress to start with or at least a similar type of functionality. Very good post!

  • surfweb

    Hi!

    I have a problem with pagination on custom taxonomy. I created a custom post type called “press”and then I created a taxonomy called “myarchive.

    The custom page on the post type “press” works fine when the page on taxonomies no. I have a 404 error page.

    I’m using the default theme of wordpress.

    Can anyone help me?

    Thanks!

    P.S: sorry for my bad English but not speak it very well

    P.P.S: Is there a way to have monthly and yearly archive about the custom post?

  • http://cairndiveadventures.com Cairns Diver

    I cannot wait for wordpress 3.1 I think this will make customs posts more user freindly on the front end of the website.

  • http://www.dharmakelleher.com Dharma Kelleher

    Well done, Adam. I have bookmarked this tutorial so that the next time I need to create a new post type, I will have your wisdom on hand.

  • Bird

    It’s funny that everyone who does a tutorial for Custom Post Types uses “movie reviews” as their example. ^_^

  • Luke

    Great tut,

    Would you be able to extend this with a description on how to add extra fields. E.g. in the movie example – how you would add release date, and perhaps a second WYSIWYG field?

  • JesusFreak

    Hello,
    I have recently added custom post types and taxonomies and I have run into a problem. When implemented the menus page malfunctions. Any ideas why? Does this happen on your end?

    • http://twodoorscreative.com Adam Murray
      Author

      Can you post the code you are using to register the post type and taxonomy?

  • osm

    friends, how can i change side of my taxonomies (genre, actors, director, writers) on the post, I always see taxonomies on the down of the post,i need change to top of post, help me plz

    the problem is http://img696.imageshack.us/i/18966854.jpg

  • Rahul

    In order to create custom post types, open your template’s functions.php file in an editor, and place the following function within the file:

    Where is this file is ? I am using wordpress 3.0.3

    • http://twodoorscreative.com Adam Murray
      Author

      Rahul,

      If you installed WordPress in your root folder, it will be located in : {your-root-folder}/wp-content/themes/{theme-folder-name}/functions.php

      If your theme doesn’t already have a functions.php file, then open up a blank document in whatever editor you are using, create one, and upload it to your theme’s folder within wp-content/themes/

  • http://awesome-media.net Timo

    Great tutorial! Thank you so much!

    Is it possible to query posts which have to taxonomies in common? Like some actor in a special genre?

    Thanks again!

    • http://twodoorscreative.com Adam Murray
      Author

      Timo,

      Thanks! This is another exciting development in WP 3.1. Many devs have seen the need for better custom queries since the development of post types and taxonomies, so I am sure that you will be seeing some tutorials on this in the near future for sure.

  • Keitai

    Hi,

    How can I organize my theme so all custom post type have there own folder. So it reads theme/mysite_reviews/single.php etc.

    And for another custom post type theme/movies/single.php

    Any tips, suggestions?

  • http://inspirationsunlimited.co.in dip

    Awesome resource. Thanks Adam. While I’m trying to implement your tricks I am successful till “Displaying via Post Query” and adding “Integrating Taxonomies via Functions.php”

    Now, 1. I am able to see 10 posts on a page however when I have 11th post, no pagination shown up.
    2. The posts which appears on this page I want the title to be linked to another website address, no able to figure out, there is no custom field option below the backend post section. 3. how do i show new taxonmy/categories through a widget in the sidebar.

    Any help would be highly appreciated. Thank.

    Thanks much for the great work and sharing the tricks.

    Regards
    dip

  • manlio

    Hi there, anybody knows How can I sort a different custom post by taxonomy, title and more…??

  • http://elie.andraos.org elie andraos

    nice tut ! it would have been nicer though to add also custom fields to the custom post type.

  • Brad

    I see my taxonomy meta fields fine on the edit screen for my custom post type, but they will not show up on the taxonomy screen for add.

    So ..with Movie Review, you click on it and it shows the add category screen but not the meta fields I have created for the taxonomy. On that same screen, if you click edit on a review, the edit screen displays and you can now see the fields.

    So I guess the question here is: How do you add a category type meta field and have it show up on the add screen not just the edit screen?

    Reviews
    Add New
    Movie Review

    • http://twodoorscreative.com Adam
      Author

      To add support for custom meta-fields, comments, etc. add the following underneath ‘rewrite’ => array(‘slug’ => ‘products’), :

      ‘supports’ => array(‘title’, ‘editor’, ‘thumbnail’, ‘comments’, ‘custom-fields’)

      That should activate every field you will need for a custom post type. If you need more, be sure to check out the Codex and search for “post_type_supports”.

      Hope that helps! Thanks for reading.

  • http://www.nextmint.com/ Daniel Juhl Mogensen

    This was definitely an interesting tutorial, and after reading this and some of the others on this site, related to custom “stuff”, I was wondering what best practice would be if your site was going to have a hell lot of content, which is supposed to be liked in different ways.

    Let’s take the “movie review site” as an example. Let’s say you make a custom post type, and named it “Movies”, and then you make another custom post type and named it “Names”. I would then like each Movie to have several custom fields eg. “Actors”, “Directors”, etc. and each of these should be linked to one or more “Names”.

    Let’s say we have the following in our database…

    Movies:
    - Leatherheads
    - Michael Clayton
    - The American

    Names:
    - George Clooney

    Then George Clooney should be linked to Leatherheads as actor & director, to Michael Clayton as actor & producer, to The American as actor & producer.

    And this should be done with thousands of names and movies…

    Any good ideas?

  • http://twitter.com/paulletourneau Paul

    Great tutorial!

    It would be awesome to read more or have a tutorial walk us through the next step which would be using these in custom pages. For example an events listing page, media releases, real estate listing and so on.

    Cheers!

    P

  • moin

    Can any tell me how to make a site like imdb.com in which all links are cross referenced you can arrange movies by actor, director etc.

    I am searching for this for past 15 days there are lot of articles on Custom Post Types and Taxonmies but after implementing every article I still not able to make because there is no complete article on this!

    Plz help

  • http://www.chillopedia.com Nadeem Khan

    Impressive – thanks for the info mate !

    em gonna ad a sponsor post type very soon !

  • http://www.theisleofavalon.com Joe Jenkins

    I thought I’d add an example of how I’ve used custom post types.

    I was asked to recreate a site for a foundation that runs various caourses, of various lenghts (1 day, weekend & longer). I just created 3 post types for eacjh of those sections, so they can easily find and add courses, without working through loads of courses, tutor info, articles, etc in the posts section.

    Once this was done, I did the same thing for sections on tutors, articles, news, etc, and now they have a really easy admin area, wheer they can just click the one they want to add to or edit.

    Not only is this easier for them, but also for me, as I will have less frantic phone calls from them :)

  • http://www.designtank.ws Chris Raymond

    This strikes me as a neat way to create a design portfolio for someone who, like me, has both print and web design work in their book. I can see having a different page template and styling for posts about print design and web design work, for example. While some custom fields would be the same, such as client, others could differ.

    The new possibilities are making me rethink my current site, which uses lots of php includes, because I never saw a theme that did just what I wanted to show my portfolio but not be a blog.

    Thanks for the useful tut!

  • El garch

    Nice tutorial, i’ve used also a plugin which do excatly the same thing, follow the link http://wordpress.org/extend/plugins/custom-post-type-ui/

  • paul

    Hi there, thanks for the great article,

    I am wondering though, while this is certainly a big step forward and can be used to help classify information powerfully, I’m looking at a situation where I need articles from various taxonomies to relate to each other.

    For example, in a music store or record label site, taxonomies would be great to classify genre’s, that either artists, or releases fit into, but what if I want to display the album releases in a genre by a certain artist, or links to the artists featured in a genre, or artists featured on an album? Same kind of issues arise when looking at a complex movie database, such as films / actors / genre’s / studio’s

    While I’m super amped with the custom post types and taxonomies, I do feel like it falls short for what seems to be a more complex “many to many” relationship management kind of system. I’d really like to see custom post type relating to custom post types, and preferably sooner rather than later seeing as I have four clients asking for exactly that. Off to hack I go I suppose…

    If I’ve missed something massively obvious to everyone else please do me a favour and tell me, otherwise any suggestions / tutorials / plugins?

    • Thomas

      Paul – it sounds like you just need to call this post type into your loop and request it by these taxonomies. Maybe I don’t understand what you’re asking but I think you could just call a new WP_Query and add your taxonomies there in the array.

      You could always add tag=movies as well, or whatever and relate them that way. The idea would be to use taxonomies like categories and tags as keywords.

  • http://www.967atc.co.uk Jamie Wright

    Great stuff, I’m making use of the custom post type and taxonomy in an FAQ page.

    In terms of the dashboard, I’m struggling to find anywhere that shows how to add an AJAX cloud, like the standard posts. Can anyone help?

  • http://truckingschoolsusa.com Mike

    I’m hoping I can figure out the taxonomies for allowing students to add trucking schools reviews to our site. Thanks for sharing.

  • Matt Edminster

    Thanks for this guide Adam. I notice that in one of your examples, you’ve used custom taxonomies to organize real-estate listings into “areas” and “agents”.

    I have been exploring options for a similar kind of application for our organization which has members functioning in multiple countries in Europe. What I’d really like to accomplish are taxonomy-like function that also bring together existing wordpress functionality.

    “Locations” would not only display the custom post types they organize, but also draw descriptive text about that location from an associated location “page”.

    Likewise, each “agent” in the “agent” taxonomy would not only pull listings organized under that agent, but also all posts authored by that wp-author.

    Any experience with these kind of integrations?

  • http://www.ovxsolutions.com OVX Solutions

    great guide,I just tried and its working very smoothly,Now i can easily jump on big database type sites in WP.Thanks for sharing and will be in touch

  • Arumugam

    Is It possible to sorting the category header in the Post Manage Page, Same as title and date sorting.

    Please advice.

  • http://www.portalpower.com.br/ Portalpower

    Por isto que gosto do tusplus, algo que procurava a muito tempo

  • http://www.shiftf8.co.uk mark

    This is a great article. I have a question I’m using custom-post-type-ui plugin and the taxonomy-picker plugin in my sidebar when I select a taxonomy from the picker I get a list of CPT’s displayed on a page. Is it possible to style that page or create a template for it.

  • http://twitter.com/dharmaksara Dharmaksara

    Wow! I think this is the easiest Custom Post Types & Taxonomies article so far. Anyway, does anyone know how to append the custom post-type slug infront of taxonomies slug, e.g. “mysite.com/my_cpt/my_taxo/my_article” instead of “mysite.com/my_taxo/my_article”

    Thanks!

  • http://cansurmeli.com C@N

    I really needed to know about this subject. And so your GREAT article helped me a lot to learn about it.

    Nicely done.

  • http://www.webartdesign.dk Webartdesign

    Thank alot…. Very good wordpress tut. Saved me alot of time. This one must be one of the best post and taxonomy tut out there…. I have just wasted like 2-3 hours on other tut that did not end up with a useful result. But this WordPress tut just work perfect…. Thank !

    Brian

  • mark shirley

    Thanks for the tutorial does anyone know how I could add the taxonomies and terms to the code below. This code displays a post type of movies and various custom fields. Is there better code to do this?.

    /* CALLING A POST TYPE OF MOVIE AND CERTAIN CUSTOM FIELD */

    <a href="”>
    image<a href="”><img src="” alt=”text-here” />
    Product CodeID, ‘product_code’, true); ?>

  • http://www.shiftf8.co.uk mark shirley

    How can I taxonomies and terms to the code below

    <a href="”>
    image<a href="”><img src="” alt=”text-here” />
    Product CodeID, ‘product_code’, true); ?>

    <?php endforeach; ?

    .

  • deepak

    a great site and this tutorial…i made almost half of mywebsite’s funtionality reading this site only
    Thanx alot:)

  • Animish

    Extremely useful information. WordPress is great and you too..!

  • Shavindra

    Thanks for clarifying

  • http://twitter.com/joanpique Joan Piqué

    Thanks, very good tutorial.

    A question: How to make a wp_tag_cloud of all tags from a custom post type?

  • http://twitter.com/joanpique Joan Piqué

    The cloud with taxonomies is incorrect, for showing an array of taxonomies the correct code is:

    wp_tag_cloud( array( ‘taxonomy’ => array(‘tax_1′, ‘tax_2′) ) );

  • Guest

    Just +1

  • NileshKacha

    Just ++1