Should Custom Post Types live outside of themes?

Wow it’s nearly a month since my last post! My head is still buried in pixel pushing for some new WordPress themes I’m working on – one of which I hope to publicly release in September – more on that in the coming weeks. One thing that has struck me in a big way over the past few weeks of WordPress development is some of the inherent constraints of Custom Post Types. It is perhaps best explained with a very real example scenario that I’m sure happens all the time.

Take your typical WordPress theme consumer Bob and his wonderful Acme Theme 2010. NOTE: The actors and themes real names have been changed in this post to protect their anonymity 🙂

  • Bob has been happily using Acme Theme 2010 for the past year. Bob fell in love with Acme Theme’s wonderful Portfolio custom post type which allowed Bob to showcase his excellent photography portfolio. Bob has added a lot of custom post types over the past year. Hundreds in fact.
  • Now Bob is not necessarily that tech savvy. Sure he was able to figure out how to buy and install a commercial WordPress theme. It was pretty straightforward actually – WordPress theme installer FTW!
  • The Portfolio Custom Posts section immediately showed up after Bob installed Acme Theme 2010 and worked straight away. Bob was a very happy bunny.
  • Fast forward 12 months and Bob thinks Acme Theme 2010 is looking a bit stale. That grungy dark theme hasn’t aged well in 2011 and Bob thinks it’s time for a change.
  • Bob finds himself a pretty cool brand new FooCorp Reloaded 2011 style theme and thinks it’s wonderful. Sure Acme Theme 2010 has a pretty sweet portfolio feature but FooCorp Reloaded has all these nifty sliders and something called a Ken Burns effect that means Bob drops his 35 bucks for FooCorp Reloaded on the spot and heads on over to WordPress.
  • Bob can just about remember the theme install process and goes ahead and installs and activates FooCorp Reloaded 2011. Bob quickly checks the frontend and with a couple of new widgets and sliders setup everything is looking sweet. Bob heads back into WordPress and clicks on the Portfolio feature.
  • It’s empty.
  • Bob refreshes the screen. Still empty….Something is wrong.
  • Bob is now close to mild cardiac arrest. Has he just somehow lost over a years work! Ouch!!
  • Bob is now about to kick off a series of support requests with FooCorp and just about anyone he knows who knows anything about what the frick might have just happened his Portfolio collection.
Of course Bob will eventually figure out that his Portfolio is not gone. It’s just taking a break – along with Acme Theme 2010. And therein lies the problem folks. Right now, theme developers everywhere are flocking to develop some wonderful custom post type implementations that really significantly enhance the value of WordPress themes. And this should be broadly welcomed. But I think we’re on the cusp of a big problem. It won’t be long before we have lots of Bob’s hitting the exact same problem as the one described above. While I understand the value of having Custom Post Types tied into the mechanics of WordPress themes, I think there has to be a better way of doing this. Who else but Justin Tadlock should offer us perhaps the best way forward! Justin wrote a great post back in February ’11 describing the process of creating a custom functions plugin – and this to me sounds like the most sensible route forward for theme developers to prevent a problem before it starts. While this solution would have solved Bob’s problem – it does potentially make theme installation that bit more complicated for end users with only the very basic of WordPress skills. Maybe there should be a way of automatically registering a functions plugin as part of theme installation process (which could then be optionally uninstalled as part of the theme deactivation process). I’m interested what you folks think on this one and any other novel approaches people take to stop this being a problem.
As WordPress more and more becomes a serious CMS platform, data independence from look and feel is going to be become a necessity.

Comments

2 responses to “Should Custom Post Types live outside of themes?”

  1. I’ve yet to find a valid use of a custom post type in a WordPress theme that wouldn’t be better served as a plugin. Maybe there are some scenarios where it makes sense. I’ve just haven’t see one yet.

    Of course, if you’re working on your own site, do whatever you want. But, if your theme is being used by others, put the functionality in a plugin.

    1. Hey Justin thanks for dropping by!

      The more work I do with Custom Post Types the more and more I tend to agree with you on this. Even for your own site or sites being managed on behalf of clients, theres a high probability that the theme is going to change at some stage and having data structures logic hard coded into theme just seems a bit short sighted.

      Ed

Leave a Reply

Your email address will not be published. Required fields are marked *