Custom Post Features could make WordPress even more flexible

One of the biggest, and most useful additions to WordPress in recent years has been the introduction of Custom Post Types. Before CPTs, all the content in your site needed to either be in pages or in blog posts. If your site needed a lot of different types of data, you’d typically use categories (or even tags) to tell them apart. I’ve seen (and probably built) examples where “products” and “news” were post categories, and the site’s front-end would continuously filter out one of the two. In hindsight: madness.

Since the introduction of Custom Post Types, it makes sense to declare separate types for different types of data. When doing so, there’s a crucial argument (passed to the register_post_type function) called “supports”. This argument tells WordPress which post features should be available for the new post type. This allows you to mix and match various features. No need for an excerpt? Require a “featured image”? Need custom fields? No problem. But there’s a catch.

Built-in features only

There’s a fixed list of features you can enable or disable. They correspond to the features present in WordPress’s two built-in types, post and pages. Nothing else. And as far as I know, there’s no (easy, developer-friendly) way to add new features. As nice as CPTs are, I think this seriously limits their potential.

Imagine being able to do something like this to create a CPT for a travel video blog.

'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'subtitle' 'video', 'geo-coords', 'event-time' )

The first four features come standard, but the real fun is in the other (fictitious) ones. Being able to add a video to a post in a manner similar to how featured images work could have many potential advantages over simply adding it into the post’s content. And although there are plugins that’ll let you geo-tag and add timestamps, not all of those support CPTs, and they do not all store data in the same way. They’re all adding data to posts, but they’re all doing it in their own way.

Plugin territory

I’m not saying all these features should be in WordPress’s lean and mean core. Most of the ones I can come up with are arguably plugin territory. But it would be nice to be able to define custom post features once, and then be able to add them to any (custom) post type. WordPress could offer a coherent, standardized way for them to present themselves and store their data. A Widget API of sorts, for the backend.

One might argue that you can do all these things using meta boxes, post meta (or extra database tables) and such, but I feel there’s a certain elegance to opening up “post features” as an API. For one thing, there are plugins that let end users define CPTs without any coding, and this would give them more things to mix and match. And perhaps, something like the functionality of those plugins could eventually make it into core…?


  1. hey roy,

    missing the paella? 🙂

    It´s a great idea, using metaboxes to add new content for a CPT is “easy” but not to fast, and more when some parameter as you say are widely used, like geo-coords (BTW, you know how to get the coords of a post writed on WP iphone app ?), meta-keywords, meta-description.

    I´m keep in thinking the core is still to BLOG that´s why WP is not take it as a full CMS.

    Saludos desde Mallorca.

    Comment by Pancho — January 30, 2012 @ 3:44 pm

    • Oh hell yes. I think your pealla ruined me for all other paellas :). Barely recognized you in your gravatar :).

      Yes, there’s still a lot of blog-thinking going on. You can do anything, but the default is blog. Guess that’s what this post boils down to.

      (no clue as to your iPhone question, sorry)

      Comment by Roy — January 30, 2012 @ 3:52 pm

  2. I am missing the paella 😉

    That indeed is one area where WordPress can improve. Having said that, I can easily get anything I want by using the Custom Meta Boxes library on Github.

    Comment by Remkus — January 30, 2012 @ 3:56 pm

    • Still, that is very much a developer’s solution. I’d love for this to get closer to the end user, and more elegant for devs..

      Comment by Roy — January 30, 2012 @ 4:29 pm

      • I hear ya .. I was just saying 🙂

        Comment by Remkus — January 30, 2012 @ 5:19 pm

    • Hey Nice code, thanx 🙂 I will give a try

      Comment by Pancho — January 31, 2012 @ 12:02 pm

  3. That indeed is one area where WordPress can improve. Having said that, I can easily get anything I want by using the Custom Meta Boxes library on Github.

    Comment by plato wedding dresses — February 23, 2012 @ 4:23 am