Developing a custom WordPress theme | 5 tips for success

Developing a custom WordPress theme | 5 tips for success

So often, when developing a custom WordPress theme, it’s easy to lose your way. To become so focussed on the end result that you forget to use logic and create something truly beautiful as well as functional.

We’ve got 5 tips for success when developing a custom WordPress theme. If you’re an absolute beginner or a seasoned theme developer there’s something here for you to takeaway and apply to your own themes.


Tip 1: Consider using a starter theme or framework

Now, let us clarify that we’re not advising you cut any corners here. What we’re saying is that there’s no point in reinventing the wheel. There’s some brilliant developers and companies out there who’ve invested huge amounts of time and effort into creating starter or ‘boilerplate’ themes for custom WordPress theme development.

What these allow you to do is save hours upon hours of your precious time, by providing you with a solid WordPress theme which you can build upon for your own purposes.

They contain a whole heap of awesome features such as (but not limited to):

  • Precoded common WordPress templates
  • Task runners such as Gulp, Grunt and Webpack to compile your assets, minify your css and check your syntax
  • Utilities such as BrowserSync for improved development workflows
  • Lean and well commented template files
  • Helpful pre-built functions
  • Theme wrappers

A few WordPress starter themes that we recommend trying out are:


Tip 2: Don’t Repeat Yourself! (DRY)

DRY is the development principle of reducing repetition of information of all kinds. When you’re developing your custom WordPress theme, you want to ensure that your theme is as lean as possible whilst still being flexible and easy to adapt.

For example, many WordPress sites will utilise a newsletter form somewhere in the content. This could be in the footer, the header or the sidebar. The point is, is that this can and will be used in multiple places. Now imagine you have almost finished your custom WordPress theme and you’ve been made aware you have a typo in your sign up form, or even a bug! Having to find every instance of that sign up form throughout your code to make the same change numerous times is going to be a long process. And more importantly, an unnecessary process.

Wouldn’t it be easier to just have this sign up form in a single file in your theme and make the update there? This way all instances of the form throughout the theme will be updated at the same time? Yes, it would, and this leads us on to our next point.

Use the WordPress get_template_part() function

This function allows you to reuse sections of code throughout your theme from a single file. For example, if you have a folder called “partials” in your theme directory and a template part called “content-page.php” in that sub-folder, you would use get_template_part() like this:

The starter themes mentioned above all use this DRY principle of development. However, we recommend taking a look through the documentation for more information on get_template_part() over on the codex.


Tip 3: Use core WordPress functions for flexibility and edibility

WordPress has a huge number of helpful functions at it’s core. However, time and time again themes are developed using hard coded information when it could have just as easily been added using a core WordPress function. Using a core function instread of hard coding information will allow much more flexible and editable theme moving forward.

For example, let’s say you’ve developed a custom WordPress theme for your website at mydomain.com. And within your theme you have hardcoded mydomain.com in each place where you’ve got a hyperlink to a different page on the site.

This would work absolutely fine. However, if you ever want to change your domain to let’s say, mynewdomain.com, it’s going to take a huge amount of work to updated each instance of the original hardcoded domain in your theme.

What you should use instead is something like this:

The get_site_url function will return the URL which has been set globally within the WordPress settings, in the admin. This allows your theme to be flexible and can be used across multiple websites without the need for code to be adjusted each time.

Some other core functions we recommend you do some further reading on are:






Tip 4: Don’t rely on plugins for everything

Firstly, don’t let this tip convince you otherwise but WordPress plugins are great! Some of them we even feel are essential. What we want to emphasise here is that you don’t always need a plugin. You can code the functionality yourself!

For example, let’s say you need to add a custom post type to your website. You could use a plugin with your theme such as Custom Post Type UI, which is great. However, you could just register the custom post type using the following code in your functions file:

The point we’re making is that plugins don’t always play nice. The more you have the more chances there are that one might conflict with another, or even with your own code, causing errors which are difficult to debug. If you use plugins for functionality which you cannot or doesn’t make sense to code yourself, you can reduce your risk of issues in the future and keep your theme as clean and independent as possible in the process.


Tip 5: Keep an eye on performance

Throughout the development of your custom WordPress theme, make sure to keep a close eye on the performance and optimisation of the theme your’e developing. Keeping a close eye on performance as you go will make for a better performing theme at the end of your development. It’s far easier than doing all the performance an optimisation tweaks at the very end, believe us!

For example, if you’ve just developed the header of your theme and it uses a 300x150px logo, ensure that your not serving up a 900×450 when it’s not required. Also, if you’ve just written a function that uses 20 lines of code, take quick look over it and ask yourself could this be done using less code? Could it be done using 2 smaller functions? Asking these questions to yourself as you go and keeping the performance of your theme at the forefront of your mind will pay dividends in the long run.

Nobody want’s a slow site now do they!

We recommend you check out WPMUDEV’s The Ultimate Mega Guide to Speeding Up WordPress


We hope that you have managed to take something away from these 5 tips to use in your own WordPress theme development. As always we’d love to hear from you in our comments below.

And why not join our growing community and sign up to our newsletter using the form below?



1 Comment


Leave a Reply

Your email address will not be published. Required fields are marked *