Why Decouple WordPress Functionality from your Theme in a Plugin?

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.

This entry was posted in blog and tagged , , , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

2 Comments

  1. Posted April 13, 2012 at 9:13 am | Permalink

    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.

  2. Posted April 13, 2012 at 12:07 pm | Permalink

    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!

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes <a href="" title="" rel=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

  • Recent Posts

    WCATL-Speaker

    Custom Post Types or Choose Your Own Adventure – WordCamp Atlanta 2014

    I’ve been fortunate enough to be able to present at WordCamp Atlanta 2014. That makes the 3rd year in a row I’ve been able to contribute to WordCamp Atlanta! Here are my slides. I’ll be posting a full blown post of my presentation as soon as I can get it all down. Plus I hear […]

    Screenshot 2014-03-17 08.12.14

    What screens want

    Great read if you haven’t yet read it yet: Frank Chimero : What screens want : http://frankchimero.com/what-screens-want/ web and interaction design are just as much children of filmmaking as they are of graphic design. Maybe even more so. After all, we both work on screens, and manage time, movement, and most importantly, change. So what […]

    bed-bug-lifecycle-stages

    Before You Report that Bug, Use this Pre-Contact, Self-Diagnosis Routine

    Wisdom for bug reporting from Newfangled There are a few things a developer usually needs to know in order to diagnose a bug, and these are the things we’re likely to come back and ask you about if you haven’t already provided them. So, to ensure we can help you as quickly as possible, here’s […]

    deathtozach-06

    In dependence – Not dead

    Great summary and call to arms to write our own content in our own ways on our own sites. Call it what you like but ‘blogging’ is somewhat waning, in the social webs. Since as easy it is to create your own site and express your own voice, we’re flocking to the ‘services’ that will […]

    Screenshot 2014-03-17 08.50.27

    I ain’t ‘fraida no maths

    I’d heard of the ‘coding maths’ series, but hadn’t watched it yet. I should have, it’s great! Keith Peters (one of the people who first got me into scripting) has a great series about the math behind coding and as always he has a way of making complex things simple to me! Learn all you […]

    Screenshot 2014-03-17 08.30.13

    Codecademy & English Computing Curriculum

    Today, Codecademy is really pleased to announce our partnership with Computing at School (CAS), the leading authority on the new computing curriculum in England. England is the first country to mandate programing in schools. Starting in September 2014, students aged between 5-16 will learn HTML, CSS, Python and JavaScript. CAS were largely responsible for designing […]

css.php