A look at WordPress 3.0 custom post types

| March 25, 2010 | Leave a Comment

kovshenin.com discusses one of the many new features coming in WordPress 3.0 that will raise its bar as a publishing platform: custom post types.

So what else could be done with WordPress’ Custom Post Types? Well, basically anything. Say you run an online store which of course has some static Pages (such as Contact, About, etc), some blog Posts, cause we’re so 2.0, remember? And Products, which would be a custom post type that contains the product name, description, product price, stock availability, and could even contain inquiries in forms of user comments!

He covers two key code snippets that gets the ball rolling on custom post types: register_post_type (WPEngineer has a great post on it) and custom functions for the edit post screen columns, which are added via a filter and an action:

The action outputs custom columns depending on the type, while the filter simply defines the columns for the Podcasts post type. It’s as simple as that. Note that I trimmed the code a little bit to fit on screen, so you shouldn’t be simply outputing 63:50, but actually count the podcast length 😉

Looks quite simple for those who know their way around PHP, but I expect plugins (and perhaps future releases of WordPress) to integrate interfaces for setting up and customizing post types.

Related Posts

Tags: , , , , , , , ,

Leave a Reply