In this article, we’ll get you started on WordPress theme development, dealing with what you need to learn before you even think about coding.
WordPress has become the most popular CMS in the world. As of May 2013, is was used by 52% of the top blogs across the globe, according to a survey carried out by Technorati and Pingdom. This is an increase of 4% over 2012, so it’s clear that the platform continues to rise in popularity.
There are over 65 million WordPress sites in use and, as mentioned, that number continues to grow. So for developers, there’s a clear opportunity to carve out a niche for making WordPress themes and create a valuable addition to their skill set.
In theory, it’s easy to make a theme and it’s something that is getting even simpler as time goes on and support gets better. All you really need to begin is an index.php file and a style.css file—but this won’t make you stand out from the crowd. And if you’re going to venture into learning a new skill, then you might as well do it to the best of your ability, right?
Before we go any further, if you want to make a great theme, then it’s necessary to have a good working knowledge of HTML and CSS, preferably with experience of coding HTML5 and CSS3. It’s a competitive market and WordPress supports both of these new standards.
If it turns out you have no knowledge of the new standards, you can get up to speed by taking a look at the Jump Start HTML5 series on Learnable or HTML5 & CSS3 for the Real World published by SitePoint.
It’s also necessary to understand that your theme will have to be compatible with the latest version of WordPress and perhaps some legacy versions too, as not everyone upgrades to the latest straight away, due to potential compatibility issues. Because everyone’s set up is different, compatibility issues may not affect everyone, so it may depend on what themes and plugins are installed on the site, or even on the server setup.
The WordPress Marketplace
WordPress coding standards are pretty strict; security is a must and it’s necessary to look into licensing, popular plugins, and the WordPress APIs before making a start on the coding side of things. In other words, do your homework. Don’t assume that because you can code, that’s all you’re going to need. It’s also worth giving some thought to how well you will be able to support the theme.
Will you have the time to:
- Create updates and patches
- Respond to customer queries and issues with their installation
- Maintain the theme and continue development
- Include code comments, which are vital to creating a theme
Take a look at the documentation on the WordPress site before getting started, so you’ll be aware of exactly what you’re getting into. Anyone can become a WordPress developer, but it’s a rigorous process if you want to get the theme approved and entered into the official theme directory.
Also, have a good look through WordPress’s coding standards to ensure that you really are up to the task before. This could help you avoid much frustration later on.
Now that you know what you’re getting into, and assuming you’ve prepared so far by brushing up on necessary coding standards, take a look around at the structure of some really good existing themes.
Themeforest are currently billing a theme called ‘X’ as being the best out there. It’s quite complex, but worth taking a look. The best place to start, however, is with the current default Twenty Fourteen theme (which is one of three themes bundled with WordPress 3.8) to get a good overview of the basic WordPress structure.
You’ll be working with about 12 core files when you begin the build process. These include:
- archive.php (for categories, posts, authors, dates and so on)
- single.php (individual posts)
- page.php (for static pages rather than posts)
- functions.php (allows changing of core functionality without editing core files)
Most of the above are self-explanatory for those that have developed a site in the past. There are also a series of PHP template tags that you insert into your code, allowing for dynamic content. When in doubt, refer to the codex to see how tags work and which are suitable for what you want to achieve.
Doing it Right
If you don’t follow WordPress’s submission guidelines, your theme will not be accepted. One requirement is that you don’t spell WordPress in any other way than I have. It seems a small requirement, but it’s an important one; no lower case P, no laziness, it has to be spelled that way and that’s that or it won’t be accepted.
While I mentioned backwards compatibility earlier, this must be minimised to one major previous version. The current version is 3.8, so that means that you shouldn’t go back beyond 3.7 when it comes to making your theme compatible with previous versions.
If you’re going to write a WordPress theme, then it’s an excellent idea to learn the APIs inside out. There are plenty of them and they are separated into sections and topics and cover the functions that are involved and necessary to build a theme.
Mostly, you’ll be concentrating on the following:
- Theme customization
However, there are literally tons more, so you should take a look at each of them and decide what you need before you begin to build the theme.
Now that you know some of what’s involved before you even get started building a theme, the next step is to look into languages, licensing, and structure. Or you could just get on with the coding and get a taste for it to see for sure if it’s something you would like to carry on with first. ## Alternative Resources
If you want to create a theme but don’t want to go through the hassle of learning the ins and outs of the codex, APIs, and compatibility issues, then you can always ‘cheat’. There are a few sites that allow you to build your own theme without going to a huge amount of trouble. These include Ultimatum, which is a drag and drop builder that you can use without any coding knowledge. It does of course come at a price, namely $65 for a starter license and £125 for Pro (lifetime) membership—so there are other options open to you if you find it too challenging trying to code your own theme.
In a future article we’ll look at code structure in more detail, submission processes, what to do if your theme is rejected, and language support. There’s so much involved when it comes to building a theme that if you want to compete, you need to build a great one. Later on we’ll also take a closer look at resources that can help you build and test your theme and more.
Update: The article was updated to remove reference to a possible permissions issue with WordPress 3.8, as this was not correct.