WordPress Theme Design Best Practises

WordPress Theme Design Best Practises

John Hewick

WordPress is actually quite addictive once you get into it. You start off with one install on your server because you need a website, find a stunning theme and add a couple of widgets. Next comes the bit where you changed a snippet of code and ta-dah! You’ve suddenly changed an essential part of your site to make it more in line with what you want and before you know it, you are mainlining tutorials on how to do absolutely everything because you couldn’t find a plugin that did exactly what you wanted one day.

Down this road creating your own theme lies. You start out with a little modification of someone else’s theme and soon, that just isn’t enough. You want more. You want to BUILD YOUR OWN THEME, DAMN IT!

Well then, go for it! Here are some best practice rules you should follow when creating your own theme.

Stick To WordPress Coding Standards

There’s nothing worse as a developer than having to work on a site where someone has their own extra special way of writing code. This means it can take hours to unpick to understand how the site is written.

WordPress have done away with this by creating standards for coding when using PHP, HTML, and CSS. These are agreed across the WordPress community and make it easier for everyone to collaborate across the platform.

The standards can be found in the WordPress Core Handbook:

  • WordPress coding standards for HTML
  • WordPress standards for CSS code
  • PHP coding standards in WordPress
  • JavaScript code standards for WordPress

Keep Theme Files Organised

Everything needs to be kept in order. With themes often including bits of HTML, CSS, JavaScript and PHP, the complexity is built in already. There’s no need to make everything more difficult.

  • Have individual template files for each page component (header.php, footer.php, etc.) instead of having them all in one messy file.
  • Keep main files in root directory.
  • Keep languages in separate files.
  • Use unambiguous titles.

Use Template Hierarchy

WordPress has a hierarchy which determines which template is used to produce the different parts of a website. To create a theme you need to know this hierarchy. You can find out about it in the Theme Handbook.

Think Global, Think Local

Because WordPress is a worldwide phenomenon, the market isn’t just based around English speakers. WordPress have made it easy to internationalise your theme.

By internationalising your theme, you make it capable of being translated. WordPress uses the GNU gettext localisation framework which changes text strings into functions so that they can be translated.

To find out more about this, go to the Theme Developer Handbook: Internationalization.

Test the Theme

To really build a theme, it has to pass the usability test.

You need to:

  1. Fix all PHP and WordPress errors using define(‘WP_DEBUG’, true); in the wp-config.php file.
  2. Check your template against the Template File Checklist.
  3. Validate the HTML and CSS.
  4. Check for any JavaScript errors.
  5. Run the Theme Unit Testfor a comprehensive check up.
  6. Test on all browsers.
  7. Beta test with real people.
  8. Clean up anything that doesn’t need to be in the final theme.


Good luck with building your first theme – let us know how you get on!



John Hewick

Author John Hewick

More posts by John Hewick