So this is all about writing CPTs into a plugin and not in your theme. Is there a time to not do that and include it into the theme? I'm thinking specifically when you are making the custom theme for the client rather than for stock. The client won't really be changing themes willy nilly, since they paid me to do it. I think separating the code sometimes can make it more complicated. It's not like if they change themes and notice some content is gone they can't change back, since the content isn't actually lost, but no longer supported by other themes. If they are my client and I do maintenance on the site or update the theme, I'd be sure to keep the CPT code in any new theme that is developed. And I'd expect that if someone else was doing the same they'd know where to look and how to continue support for the CPTs. I guess it comes down to the expectation that clients don't really need to be changing the theme. If they knew what they were doing changing themes, then I think they should understand that some functionality may be tied to the theme. Or maybe that's the point. Functionality traditionally has been in themes, and we should be moving away from that?
Personally I think it's easier to tell a client to come to me or at least ask if they want to change the theme (not that I'm locking into being my customer) that it would be for them to figure out some message saying the site requires a theme and a plugin in tandem, while it will still kinda work with one and not the other, it will be incomplete either way. Are we expecting them to be able to change themes, and update to new one to display the CPTs properly?
Embedded Link
Theme-ready Custom Post Types in WordPress – Jumping Duck Media
Good advice on decoupling WordPress Custom Post Type implementation from your themes. How to notify a user that some functionality of the theme might depend on a plugin that defines the CPTs. How to override theme template selection from a plugin.
Theme-ready Custom Post Types in WordPress – Jumping Duck Media
Original Article: Theme-ready Custom Post Types in WordPress – Jumping Duck Media
Dougal Campbell's geek ramblings – WordPress, web development, and world domination.
I think it just depends on the situation. The most common use-case is probably as you described: Custom Post Types will be developed for a specific client, and tightly coupled with the theme, which they are unlikely to change willy-nilly.
But, if you wanted to develop CPTs for more generic re-use between different sites (or just to be resilient to theme switching) , that article points out some ways to deal with the theme coupling/decoupling.
I think it would be nice if some plugin and theme developers got together and worked on a common baseline framework for some common CPTs: Events, Products, Real Estate, Music/Movies, etc. Something akin to how Post Formats defined a loose baseline for different types of posts.
Agreed! I've just seen some people get pretty heated about separating all functionality from the theme and putting it into a theme plugin. They seem to think that it's never a good idea to have functional themes. I do agree that structure and content should be in the html, style in the css and interactivity in the js (unless you can have it powered somewhat by css3 of course). But I don't think it needs to be that strict when it comes to themes and plugins. Thanks just my take and I was curious regarding your thoughts… and I love the answer: "it depends". That about sums up web develpment!