1. Code
  2. Theme Development

Making the Perfect WordPress Theme: Bad Practices

Read Time:5 minsLanguages:
This post is part of a series called Making the Perfect WordPress Theme.
Making the Perfect WordPress Theme: How to Code Well
Making a WordPress Theme: Maintenance, Compatibility & Support

We discussed how to do good in the previous part of this series: We learn how to write better code, how to comply with the standards, how to make our code readable by others and so on.

In this article, we're going to see how to do bad: We'll go through some of the worst practices that one can follow when building WordPress themes.

Reinventing the Wheel

Reinventing the wheelReinventing the wheelReinventing the wheel

Sometimes, there's no need to do everything from scratch. If you were manufacturing car motors, what would be less time consuming and cheaper: Manufacturing the bolts yourself, or buying bolts from a bolt manufacturer? Obviously, the logical move would be to buy the bolts from somewhere else.

The Function Reference in the WordPress Codex is a place with a lot of hidden gems. The function which obfuscates email addresses - antispambot - or the one which prepends your strings with zeros when necessary - zeroise - are some of the tiniest gems, and there's many more like these.

All you have to do is read the reference from the top to the bottom and take note of the functions you find useful. ( is also a helpful reference.) In doing this, you may find a function for your theme that's useful that you never knew existed.

You can also think about outsourcing features for your theme. If you need a jQuery slider, you don't have to write a jQuery plugin from scratch and integrate it to WordPress: You can buy a developer license of a premium jQuery slider or use a free one that allows commercial usage.

Instead of losing time on creating a tabbed interface with jQuery, you can just take a widely used jQuery plugin with an appropriate license and use that. No need to design a simple set of backgrounds for days - download one with the proper license, use it and give credit to the designer!

Warning: Don't think that you don't have to read and understand the code you're using. Don't be that guy.

Invading the Plugin Territory

Stay out of my territory!Stay out of my territory!Stay out of my territory!

This is a widely discussed topic across the WordPress community: Can we (or should we) provide functionality within WordPress themes?

The rule of thumb is this: If the feature is about the visual appearance of the website, it should be in the theme, but if it's about the functionality of a website, it should be included as a separate plugin. So if your theme has to change the rewrite rules or make use of custom post types or taxonomies, it would be best to serve these features as plugins. The TGM Plugin Activation Library would come in handy in this case.

And you should keep in mind that you don't have the right to shackle users to use your theme forever. If the user generated content disappears when they change the theme, this is a mistake that the author of the theme should fix. This usually happens when a theme makes use of custom post types and taxonomies and it should be made right by utilizing custom made plugins.

Offering Simply Everything

Offering too muchOffering too muchOffering too much

There are themes that offer 200+ background images and 1000+ icons ready to use. They also include over 2000 shortcodes to choose from, 10 different sliders, and of course, they have over 1000 fonts available.

Awesome, right?

Wrong. Nobody needs to choose from 10 sliders. Nobody will use 200 background images. Nobody can possibly make use of all 2000 shortcodes that you offer. You will work day and night on those features and more features, but in the end, they are never going to be used.

But, unfortunately, it makes the theme sell. Even though it's a cardinal sin to release an "all-purpose" theme with all the features above, we can't argue that it draws attention when a theme has so many features, even if you won't use any of them. It's a hard truth. But the harder truth is that they sell fast at first, but when people realize that it doesn't mean anything to have 1000 shortcodes, the theme gets a 1 star review and sales drop.

Luckily, this trend is coming to an end - we don't see many "all-purpose themes" lately. You don't have to waste time to make your theme suitable for every single person on earth: Know your niche and make themes with realistic features.

Too Many Files, Zero Optimization

A fat cat is the perfect metaphor for a bloated WordPress themeA fat cat is the perfect metaphor for a bloated WordPress themeA fat cat is the perfect metaphor for a bloated WordPress theme
A fat cat is the perfect metaphor for a bloated WordPress theme!

This is connected with the "bad practice" above: When you try to squeeze more and more features in your theme, your theme gets fat. Your img folder gets fat, your js folder gets fat, your library folder gets fat and before you know it, your theme pushes a quarter of a gigabyte. You wouldn't install a 150MB theme with 1000+ files in its ZIP file, would you? Of course not. So don't make something like that.

It also causes themes to load way slower than usual and sometimes fail to work completely. When you forget to optimize your code or your assets, it literally hurts your customers.

I wish I was kidding or exaggerating, but I once worked with a theme that suspended my client's hosting account. It was a shared hosting plan and the website wasn't even getting any hits yet, but I created some pages, previewed them and pow, the hosting provider offered a "better hosting plan" after suspending.

After all, an optimized theme beats a bloated theme, no matter how the fat one looks. Make sure your theme loads nothing more than just a few JavaScript files, one CSS file, maybe a font and a minimum amount of images. (Don't forget how handy CSS sprites could be!)

Also, don't forget to optimize your PHP code: Learn how to make fewer database queries and use fewer PHP functions.


So, these were the things you're not supposed to do. I hope you (and me, as a theme developer) don't make these mistakes while developing new WordPress themes.

Do you have any additions to these bad practices? Share your thoughts and experiences below!

Looking for something to help kick start your next project?
Envato Market has a range of items for sale to help get you started.