WordPress 3.0 will introduce a simple programatic way for developers to create custom post types. I’ve seen people talking at length about this feature, but most discussion focuses on how you can have a custom display for certain content, support custom URL structures or manage content differently. These things aren’t new – they are all things you could do previously without too much trouble by using a little custom code with taxonomies or post meta (especially with the Carrington framework).
No, the real power of custom post types is more subtle – it removes those posts from default queries.
Selecting posts based on certain criteria has always been pretty straightforward in WordPress. What has been hard has been excluding that content from all default queries (home, archives, category, feeds, comment feeds, etc.). By using a custom post type, you can easily exclude content from these default queries, and this is a huge win.
This post is part of the project: Carrington Core. View the project timeline for more context on this post.
Great point Alex. This is the first post I’ve read emphasizing this.
The other big benefit of custom post types often overlooked is the improved user experience in the backend. Using taxonomies or post_meta made it quite awkward for the user to manage different content types in the backend.
Actually we had built a set of tools that we’d use on custom site builds that would give users a very good experience in dealing with different content types (perhaps better, in some cases). Though it’s nice that there is built-in support for this now.
Hmm good point, I hadn’t thought about it but it’s obviously very true!
Very true! I’ve had to deal with that problem before. I’m really looking forward to 3.0.
i love that i can have custom taxonomies and postmeta for each new type i define. we’re already using it on a bunch of projects.
Funny, Otto had to use quite a lot more words to basically say the same, but mean something different: http://ottopress.com[...]-post-types/
This is exactly why I was pumped when I saw WP 3.0’s custom post type support. Keeping my portfolio posts out of my blog was a PITA that I’m happy not to have to deal with any more, as I now have a proper “portfolio” post type.
Indeed, I am looking forward to the new release. For a while I’ve been using a specialized category (‘portfolio’) to separate portfolio pots from normal posts. This requires some pesky filtering in a few places.
I’m running the latest beta locally, and plan to work on implementing a new Portfolio custom type, and port the contents of my portfolio category over. Then I can simplify my theme templates.
@Grant, you mention porting the contents of a category to a new custom type. Is there any automated way to do that, or will we have to wait for a plugin?
UPDATE wp_posts SET post_type = ‘your-post-type’ WHERE…
[…] Why Custom Post Types are Great […] the real power of custom post types is more subtle – it removes those posts from default queries. […]
Funny. I’ve been thinking about how such a feature, by default, would be nice…for about six years, since posts on your blog and a couple of others made me upgrade my rusty B2. And now, when it’s finally here, I overlook it. Thanks for making my day. 🙂
Pardon, forgot something. I have a stupid question and I would really love to get an answer to it. Let’s say that I am going to convert many things done by hand on a long-running website to custom post types with custom taxonomies. Given that I’m not 100% sure about the hierarchy and that everything’s done through functions.php, how can I assure that, whenever I make changes in that particular file, those changes get registered? Thank you.
Great insight. For that and many other reasons the inclusion of Custom Post Types really going to be a watershed event for WordPress.
You’re absolutely right. When I first look at custom post type, I was confused with custom taxonomy because I thought I could do everything with this by using custom taxonomy. But you’ve just shown a great point of using custom post type here. Thanks for sharing.
Interesting, I’ve yet to use this, but I may just start using WordPress as a CMS with this new feature.
@Dave, I had figured on some copy and paste, since my portfolio’s not all that big 🙂 But Alex added a comment indicating how this could be done with a query.
Oops, wrong link. The right one.
Thanks, Grant. Wish I could do copy and paste, but I’m thinking of converting a category with 617 posts in it! Keeping it out of the loop, the feed, the recent posts widget, etc. and applying special styles and rules has always been a hassle, so creating a custom post type would simplify things enormously. Clearly I’m going to have to learn how to do database queries, then.
If you need help with that, my WordPress HelpCenter team can hook you up:
http://wphelpcenter.com
Maybe (probably) I’m being dense here, but why not just use pages? They, too, are out of the loop.
I used pages in my blog for a type of content that was unlike my posts and that I could link together as groups and subgroups.
Would moving them to a custom post type be a good idea?
By using a custom post type you can:
– have date-based organization instead of hierarchical
– use taxonomies
You can’t do that out of the box with pages.
[…] Alex King nous donne son avis sur l’une des plus innovantes nouveautés à venir dans WordPress 3.0. […]
So where is the data in the custom taxonomy fields stored? How does one query against it?
Since we don’t get to create appropriate data types for the fields, is it all saved as text? Won’t this make retrieval inefficient, especially if there are lots of these custom posts?
I saw a presentation on WP-TV about how a contact manager could be created, with a custom post type for holding the contact data. Made sense in terms of separating that data from posts, and in making data entry make more sense for non-techies. But is this kind of thing scalable?
[…] Why Custom Post Types are Great […]
[…] Published Why Custom Post Types are Great | alexking.org. […]
This is so overlooked, in fact, that I didn’t realize that I had to add it BACK IN to some queries for them to show up! This post really helped me in the right direction for that. Thanks!