Best Practices in Theme Development – Orlando WordCamp 2012


At the Orlando WordCamp 2012, I sat in on a talk by James Tryon regarding best practices regarding theme development and I wanted to share some of his points, as I think they’re of good value, for anyone who tinkers with themes:

  • Think about workflow: make it obvious how certain tasks are achieved, particularly in the back-end.
  • Your client shouldn’t need you once you turn the site over: everything should be sufficiently obvious that you client can update and maintain their own site.
  • Use _s as your starter theme for custom theme work. It is by far the best way to build a theme without unnecessary duplication of effort.
  • If something adds functionality to a site, it belongs in a plugin, NOT IN A THEME!
  • Learn how to use get_template_part and start using it!
  • Only load functions on the pages they’re needed.
  • If WordPress does it, use it. Don’t reinvent the wheel!
  • Never load CSS or JS in the header or footer directly: use wp_enqueue_script and wp_enqueue_style instead.
  • Use the built-in Theme Options functions for allowing the user to set colors, headers and layout.
  • Put plugins that deliver core site functionality in the mu-plugins folder, so that they can never get deactivated, not from the plugins screen, nor from switching themes.
  • Shortcodes can deliver a lot of custom functionality (custom loops, styled elements) that are easy for clients to remember and use throughout their site, which puts a lot of power in their hands. Consider using them where appropriate.
  • Make sure you use the WordPress Coding Standards (0 – not 0px, media queries at the bottom etc.).
  • You don’t have to design responsively, but at least make sure that it works on mobile devices. If not, fix accordingly.
  • Test with WP_DEBUG to make sure your theme isn’t throwing up any errors. Also think about using BrowserStack for cross-browser testing.
  • Invest in useful premium plugins that will deliver you a lot of customization ability and save you a lot of time, like Gravity Forms.
  • Make sure you compress all of your imagery to improve load time and reduce file size.

So, what did you learn? Or what do you have to add to the list?

You can see James’ slides here and hopefully, the session will make it on to soon enough

7 thoughts on “Best Practices in Theme Development – Orlando WordCamp 2012”

  1. Rilwis says:

    There’re some debates on putting shortcodes in a plugin or theme, and there’re many plugins for that purpose. But in some limits like styling elements (boxes, lists, quotes, etc.) I agree with you that shortcodes should be implemented within themes.

    And I love the _s theme! That’s a great start for building theme. Everyone can learn something from this.

    1. Well, I can’t think of a single reason why shortcodes should be included in themes – as soon as the theme changes, all of the content within those shortcodes is broken, or doesn’t display.

      I built my first two themes from _s – it’s a perfect, well-coded and commented starter for anyone.

  2. James Tryon says:

    Thanks for the great Write up. The slides can be found on my site.

    @Rilwis If the theme changes the shortcodes will die and all your old blog post will be filled with dead shortcodes. Moving them to a plugin will pervent that from happening.

  3. Shea Bunge says:

    One thing I don’t necessarily agree with is putting plugins in the mu-plugins folder. If they’re custom plugins that you’ve written, then that’s okay. But putting plugins in mu-plugins will block updates – and that’s bad.

    1. Shea, that’s true, but the point was to move custom functionality from themes into mu-plugins, so they wouldn’t require updating anyway.

  4. vajrasar says:

    Am Sorry, am a newbie and I never really got _s concept. I though have heard and seen Stalkers theme in play, where it gives you a bare theme with nothing to work on. Is _s kind of same?

    1. Yes, _s is the same in the sense that the theme has absolutely no styling, however, it is completely built out, so all you need to do is add the styling and you’ll have a very functional, well-coded theme.

Leave a Reply