Adding custom post types to WordPress 3
In the latest version of the WordPress blogging platform, the developers have (finally) introduced Custom Post Types, allowing it to become more of a CMS without extensive use of plugins. Unfortunately, after installing the latest version, you’ll probably have noticed that there doesn’t immediatly appear to be any way to create your own. That’s because there is no UI to do this with – doh. The way to do this is to use the recently introducded method register_post_type().
The Example
Lets say you are running a blog that will have podcasts as a content type every so often, but you don’t require a heavyweight plugin like PodPress – Custom Post Types are the perfect solution.
The Code
Take a look at the following code:
‘label’ => __(‘Podcasts’),
‘singular_label’ => __(‘Podcast’),
‘public’ => true,
‘show_ui’ => true,
‘hierarchical’ => false,
‘query_var’ => false,
‘supports’ => array(‘title’, ‘editor’, ‘author’)
));
Whack that straight in your theme’s functions.php file and voila – you’ll see the new Podcast custom post type right there listed underneath the Comments button. So what did this code do exactly?
The Parameters
As you can see, all we’re really doing is calling the new register_post_type() method and sending through some parameters:
- Label is pretty straight forward, what do you want the custom post type to be displayed.
- Singular label is also intuitive, what do you call ONE of your post types.
- Public is a meta argument to determine whether your post type will be accessible via search, menu’s etc… (more about this on wordpress docs)
- Show UI - set to true to show the custom post type on the back end. False can be set to allow extra content to determine how the custom post type is displayed in the back end.
- Hierarchical is a parameter to determine whether each custom post can have or be a parent of another.
- Supports allows you to determine what content creation fields are used when creating or editing a custom post:
- ‘title’
- ‘editor’ (content)
- ‘author’
- ‘thumbnail’ (featured image) (current theme must also support post-thumbnails)
- ‘excerpt’
- ‘trackbacks’
- ‘custom-fields’
- ‘comments’ (also will see comment count balloon on edit screen)
- ‘revisions’ (will store revisions)
- ‘page-attributes’ (template and menu order) (hierarchical must be true)
The Results
Shown below: the new “Podcasts” custom post type. Now start filling that bad boy with some content!
Related posts:
Leave a comment

[...] Adding custom post types to WordPress 3 [...]
200 Awesome Fresh Articles for Designers and Developers | tripwire magazine
July 8, 2010
[...] Adding custom post types to WordPress 3 [...]
200 Awesome Fresh Articles for Designers and Developers | TechFleck
July 8, 2010
Do you know how to include the podpress meta box in a custom post type?
PKGMULLET
October 20, 2010
[...] @andygirvan Social MediaRelated Posts Adding custom post types to WordPress 3WordPress 3.0 – What’s New & How to PrepareIncase you missed it – WordPress [...]
Is WordPress the right tool for the job? | Andygirvan.com
June 15, 2011