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 wordpress.tv soon enough