Custom Post Types are getting all kinds of hype right now, but if you are like many others you’re probably wondering “what does it all mean?” and “how does this affect my site?”, let me explain.
What are Custom Post Types?
Custom Post Types extends the existing WordPress infrastructure that already handles Posts and Pages to support other types of data. In essence the name says it all ‘custom’ ‘Post types’.
WP Engineer (my favorite WordPress site for techies) demonstrate a custom Post type for managing Movies. Pretty smart!
Custom Post types benefit our project, WP e-Commerce, through internal database optimizations, removing the need for additional database tables by utilizing existing WordPress infrastructure, a great example of this is the Products table.
WP e-Commerce extends the standard custom Post type interface instead of re-inventing the wheel resulting in a lightweight Plugin that changes with WordPress as it updates, what this means for WP e-Commerce is less ‘catch up’ Plugin updates to ensure compatibility with the latest WordPress release.
Examples of Custom Post Types
Here are several examples of custom Post types in the wild.
Countries Custom Post Type Plugin
Installing the Countries Custom Post Type Plugin on your site adds a list of all the countries of the world to your WordPress install. Developers can use this list of countries for their own ideas and websites.
Essentially the goal for a Plugin like this is for it to become a core Plugin that can be used by other Plugins & Plugin developers to wrangle and manage country related information. So for instance for the WP e-Commerce Plugin we can remove tables in the database that store country related information. And we can rely on WordPress to store that data instead. For BuddyPress we would like to see this Plugin being used to enhance BuddyPress Profiles because every WordPress user comes from somewhere!!
WP Wiki Plugin
So you want a Wiki? Tired of banging your head against a wall with Media Wiki?
When WordPress introduced post revisions in 2008 a whole new range of possibilities opened up. Questions like, “would it be possible to make a Wiki site using nothing but WordPress?” started to pop up on the internet. And of course the answer was inevitably yes. The Wiki Plugin does exactly that – the latest version has been reworked to use Custom Post Types. Here is what lead developer Matthew Gerring has to say:
“When you install a WordPress Plugin, you want it to look, feel, and act as intuitively and smoothly as the rest of WordPress, just like when you install a new app on your computer. The new version of WordPress Wiki accomplishes that with style, using Custom Post Types. They allowed us to create an experience that’s totally integrated into the rest of WordPress, without feeling like anything is hacked or bolted on.
We expect most people will use WordPress Wiki in conjunction with other content on their site, so Custom Post Types were an obvious choice. You get a separate panel to manage your content, complete with all the advanced editing, revisioning, and comparison features users expect from a robust collaborative editing tool. WordPress Wiki is deeply integrated into WordPress in other ways as well, minimizing Plugin conflicts and frustrating errors and maximizing user happiness.”
WordPress Wiki Plugin (Official)
WP e-Commerce Plugin
WP e-Commerce is a free bolt-on shopping cart that lets customers buy your products, services and digital downloads online. The newest development version of WP e-Commerce utilizes Custom Post Types. Here is what I’ve got to say about our move to Custom Post Types:
“Before there were Custom Post Types and Taxonomies we had to create numerous Database Tables for storing Product Related information. Last year Matt Mullenweg suggested that we get rid of as many tables as possible in favor of Custom Post Types. Ever since that day we’ve been on a mission working to achieve that goal.
We’ve made a really good start by removing at least half of our database tables and we have plan on getting rid of more, first of all we will be bundling the Custom Post Type Countries Plugin in WP e-Commerce 3.9 which will eliminate database tables that are currently required to store customer / shop owner location (base of operation) and tax related information, then once this has been done the only remaining tables will be related to purchase logs – Barry Abrahamson from Automattic told me that tables for logging information are ok and that we can be forgiven.
Again to reiterate what this means – we have been able to borrow functionality that comes free with WordPress making WP e-Commerce a much tighter, lighter and sexier Plugin. Its very very nice.”
WP e-Commerce Plugin (GetShopped.org)
This is a good example of how businesses use Custom Post Types in the real world – this project is what they call an “Industry Leadership initiative” being developed by Instinct and run by Xero. In the accounting world there are a number of industry standards that define things like an invoice and a packing slip (among many other things). All these standards are available online for people to see however in the past all these standards have been locked down (read only) in an old fashioned static websites. But not any more.
Each standard (i.e. the industry standard for an invoice) has a corresponding XSD/XML file, on its own you can’t really do much with an XML file so Instinct created a WordPress Plugin for importing these files and turing them into corresponding Custom Post Type entities in the simpleubl.org database. Now thanks to Custom Post Types industry leaders (Xero, FreshBooks, MYOB, etc.) can monitor and discuss industry standards on a dynamic website and use common social networking tools to discuss the future of those standards.
Custom Post Type UI
This Plugin provides an easy to use interface to create and administer custom post types and taxonomies in WordPress. This Plugin is created for WordPress 3.0.x
Custom Post Type UI (WordPress > Extend)
Before WP3 came out, Real Estate agencies and agents were pretty limited in how they could create a Property Listings site. There are Premium themes out there that made this possible, however the separation of Properties and things like Blog posts was not well defined which makes content management difficult when you are managing (for example) lots of Properties.
Jeffrey Pearce from WooThemes talks about their new theme Estate tackled this pain point:
What we did was make use of WP Custom Post Types and Custom Taxonomies. We also customized the edit properties section for further flexibility with additional search filters and a better all round edit dashboard.
The other thing that we did was take advantage of the taxonomy system, by creating some additional Custom Taxonomies for the properties, such as location, property types, and additional features. This allowed us to use a lot more of the WP built in functions like the page templating using taxonomy.php and modifying the loop using the post_type argument.
I really found the whole separation of content made building the Property search much much less complex than i expected And the custom taxonomies allows for more dynamic content, for example, you can structure your Locations in whatever way you like, a flat single hierarchy, or a multi-level hierarchy.
Estate Theme (WooThemes)
The guys over at WooThemes also used Custom Taxonomies on their Unite theme. This theme uses their tumblog functionality which makes a WordPress theme function much like tumblr does.
Our first release of the tumblog themes with Cinch, Slanted, and Retreat used WordPress categories to separate the different tumblog posts such as image posts, article posts, quotes, etc and you as the user had to set this up in our Theme Options. However, after a suggestion from Matt Mullenweg to use Custom Taxonomies to separate the tumblog posts, we implemented this into Unite.
How this helped? Well, again we could take advantage of the taxonomy.php templating which also helps our users out when they want to customize their theme. But it also added another layer to posts for separation and management of content.
It also allows our users to further categorise their posts not only using the default WordPress categories, but also using the tumblog taxonomy. And these changes are going to be included into the upcoming iPhone app for our tumblog themes
But probably the biggest win out of everything for me as a developer, was that it ended up simplifying a lot of the code. If I think of Estate and the amount of custom functions that I would have had to have written, it would have taken a lot longer to build and release. Also it’s allowed us to refactor certain of our existing themes to make them better I’m already working on an improvement to our events theme, Diarise, using Custom Post Types.
Incidentally, when our WooNav got included into the WordPress core, the core of it was rewritten to use custom post types.
Unite Theme (WooThemes)
Our friend Ryan Helleyer from PixoPoint has made a nice slider gallery for their website. Its really nice and we hope that one day its turned into a WP Plugin.
For a while now we have been hard coding the slider gallery on our home page. This was very annoying when changes were needed in the gallery. To get around this, we considered setting it up to pull the data in from static pages, but this seemed like an awkward solution as it would have made a mess of our list of WordPress pages and those pages could have turned up in our search results which we did not want.
Custom post-types provided an excellent opportunity to clean up this area of our site and to make the administration of the gallery much simpler. We can now add as many or as few items to our slider gallery as we like and when we want to change them we can simply modify the posts in our admin panel without worrying about messing up other areas of our site. The images in the slider are provided via post thumbnails which are automatically resided and cropped to match the size of the slider gallery.
The Forum Plugin uses three post types for handling forum structure:
- Forums: This is your top level, which holds everything else
- Topics: Children of forums and use the topic tags taxonomy
- Replies: These are the individual posts made within a topic
I had originally taken a different route of using a forum taxonomy, topic post type, and reply comment type. However, using that structure had major limitations.
I’ve been tinkering around with the idea of building a forum Plugin, so I decided to get behind the project completely and make it happen. What started out as a simple project quickly turned into something that a lot of people have been wanting — a forum Plugin that fully integrates itself within WordPress.
Forum Plugin (Justin Tadlock)
TB Testimonials Plugin
This is a nice lightweight WordPress Plugin for handling Testimonials using Custom Post Types.
TB Testimonials Plugin (Travis Ballard)
WPML.org – a case study
WPML is a Plugin that can turn WordPress into complete multilingual content management systems. WPML lets you translate your site’s contents and theme. It can also add navigation elements for building full websites, not just blogs.
Recently the guys over at WPML overhauled their site to familiarize themselves with Custom Post Types.
Using custom post types and custom taxonomies, we were able to turn icanlocalize.com from a big mess into an elegant website, that’s easy to maintain and translate.
It was really fun building icanlocalize.com using WordPress. The visual editor and media management make it easy to get contents online quickly. But, like many newly weds, after the initial excitement, real problems begin surfacing.
Simple Custom Post Type Archives
Adds friendly permalink support, template files, and a conditional for public, non-hierarchical custom post types.
WordPress 3.0 opens the door for entirely new content management possibilities with custom post types. As awesome as it is, the first version to implement custom post types is missing a few things. This plug-in patches one of those holes: templates and friendly permalinks that enable “archives” for custom post types, much the like the “blog home” is an archive for all “post” post types.
Simple Custom Post Type Archives (WordPress > Extend)
Games – Level Data
This project is still in its infancy however it is a very interesting use for Custom Post Types. The website Game Makers is a social networking site whereby users can setup an account and start to make games – not just any games but real games. We’re talking side scrolling games and eventually top down games like Zelda.
We use Custom Post Types to store level and game data. So what that means in human terms is that the post type.
If you’re still wondering about Custom Post Types then this article has failed you. Custom Post Types are there to make WordPress more powerful, maybe not so important if you are a content creator, but for developers creating Plugins and making new websites then you need to know about Custom Post Types.
Some people are even suggesting that WordPress Custom Post Types are going to be the feature that kills Drupal? I rather, just hope for the best.