Creating a high quality WordPress Theme is about more than just a nice design. What’s going on under the hood is equally important: using the right Template files, writing clean code and testing for all kinds of content.
Luckily there is a wealth of information, plugins and other helpful tools available on the web. This is an overview of the best resources to help you develop Themes according to the best practices.
For those new to Theme Development, the Theme Development article in the WordPress Codex is a good starting point. It gives an overview of all of the different aspects of a Theme.
If you want a more hands on approach, work through the ThemeShaper WordPress Theme Tutorial: 2nd edition. It is divided into 16 lessons, with code samples and detailed explanations that will help you build a Theme from scratch.
There are other approaches to building WordPress Themes, a very comprehensive overview of the options for WordPress Theme development is available on Smashing Magazine.
WordPress has well established coding standards for PHP, HTML and CSS. Following these standards will make it much easier for other developers to read and modify your code.
Localization and Internationalization
Making your Theme translation ready is strongly recommended. In developer speak this means l10n and i18n, and the Codex has an introduction about the code side of internationalization.
If you are multilingual and want to translate a Theme, you can look at the Files and Tools page in the Core Contributor Handbook.
Theme Options and the Customizer
Thanks to the Settings API, you can create a custom settings page in the WordPress Admin to help users customize your Theme.
Proper handling of Theme options is very important, so if you build a custom options page, please follow the instructions in this tutorial.
With WordPress 3.4 came a very cool feature, the Theme Customizer. It allows users to change the appearance of a Theme via different controls, while being able to preview the changes live.
Leveraging the Customizer in your own Themes is pretty straightforward, and Otto has written three comprehensive tutorials to get your started:
- How to leverage the Theme Customizer in your own themes
- Theme Customizer Part Deux: Getting rid of Options pages
- Making a custom control for the Theme Customizer
Testing your Theme
- Log Deprecated Notices helps you to find calls to no longer supported WordPress API functions.
- Theme Check is an automated check of your Theme against a set of Theme Review Guidelines.
- Theme Mentor is based on the Theme Check, but it performs a larger number of tests.
- RTL Tester helps with debugging Themes with support for right-to-left reading languages.
- Monster Widget helps with testing WordPress core widgets without having to add them one by one to each widgetized area.
A Theme should be able to deal with a variety of user generated content. To help you to test your Theme, you can use WordPress’ Theme Unit Test.
The test consists of a XML file that you can import into your development environment as well as a set of instructions on how the Theme should handle the test data.
If you want a more exhaustive set of test data, you can download WP Test by Michael Novotny. WP Test is an Open Source project and the data can be found on Github as well, so if you encounter a bug that isn’t covered, don’t be shy and contribute.
In addition, there is The WordPress.com Public Theme Guide, that outlines essential guidelines for high quality Themes on WordPress.com.
There are a couple of well developed Themes that can serve as a showcase for development best practices.
The _s Starter Theme is another good inspiration and can serve as a foundation for building your own custom Theme.
And finally there is Oenology, a Theme that has been specifically build to serve as an educational reference for developers.
Themes are an often discussed subject at WordCamps. Here are a few interesting presentations that you can watch:
- The State of Themes
- 7 Tips for Better WordPress Theme Development
- Beyond the Guidelines – Theme Development Best Practices
- Approaches to WordPress Theme Development
- Designing for the modern web
- Theme Busters “R” Us
- Accomplish It With Core: Galleries, Sliders & More
Did I forget something?
Let me know in comments or write a post on your own blog.