What makes a good WordPress theme

I’ve been reviewing themes for quite some time and over the course I’ve learned a lot about the good parts, the bad parts, and the in betweens. All these themes have a few things in common. What I like to call guiding principles. I think of them much like I do the principles of design; simple rules to making a WordPress theme.

We all have our take and this is mine:

  • Error free
  • Follows core implementation and best practices
  • All around user-friendly

Just three things. Sounds a little crazy but it is true. I’ll explain each one a little more.

Error Free

Yes, error free. This includes CSS, JavaScript, HTML, and PHP. Now, that sounds simple right? It can be. What I mean is not just those. I also mean WordPress related errors. Believe it or not, there are times when WordPress does throw out some errors.

If you know, or follow, WordPress development, you know there are a few things to look for. Four functions and one setting can do a lot of damage. The _deprecated_* functions, _doing_it_wrong, and define( 'WP_DEBUG', true ) can create a very bad experience for not just users but end-users as well. Clearly we would like to avoid all of these things when possible. There are times when some things are not possible but you can prepare for some.

Yes, there are times when CSS/HTML may create an error but it could be caused by a user inputting arbitrary HTML/CSS in some form or another so that takes less precedence. The ones to be super mindful of are JavaScript, PHP and the WordPress related ones because as a theme author you can control this. You can do this by using an alpha version, beta version and release candidates. There is a plugin that allows you to do this: WordPress beta tester. It is a great and powerful plugin for themes and plugins to take advantage of. You know the best part about it? It’s FREE!

Best Practices

Yes I said it. The thing to remember here is that those can change. Much like core does and has. To elaborate, a theme should be able to be switched without the user even having to worry about losing any content. A theme makes the design decisions. No, I don’t mean a user can’t change colors or even a layout but it does mean that it should have only the needed options. Minimalist if you will.

A good example of this would be the Twenty Fifteen theme. Yes, I am linking to it because it has a great color scheme selector. Notice that it doesn’t have options for specific things the theme has. There are some that use the customizer for link colors, header title changes and simple things that a CSS plugin can do or even a child theme. Yes, a child theme. Any theme can have a child theme. If it makes it hard to create one, odds are you may have to rethink a few things.

As I mentioned there should be no reason for a user to lose any content. What this means is as a theme author, you have to think about what is being saved to the database. What things can be migrated when a user wants to change from Theme A to Theme B or Theme D.

Yes, that can feel limiting but let me give you an example of this. You buy an iPod – yes, they still exist – but you had a Sony mini-disc player – yes, they too, still exists – and you want to transfer all your music to the new iPod. Well, the Sony player used a different format for saving those songs you loved so much. Yes, Nicki Minaj, Alice Cooper, Aerosmith, Beethoven, and that Blues Clues theme you wanted to transfer over won’t play because they are in a different format. You’ve created more work for not only the user but a terrible experience as well. You’re going to tell your friends the iPod doesn’t support this and can’t do this and that and all because the mini-disc player ( your theme ) didn’t follow a standard of MP3.

Yes, it does seem a little off to mention that but think about what the next theme author will have to explain. You may be the next theme author that explains why their slider isn’t showing up in the right place.

Friendly

And I mean FRIENDLY! Okay, now that the sugar has somewhat worn off, let me explain a little more. A theme is child friendly and plugin friendly. What do I mean by child friendly? Simple.

WordPress has a great way of making themes and making those changes without a user having to lose a lot of those changes. A great way of course is through a plugin. Another is a child theme. What’s amazing is that a child theme overrides the parent theme when it comes to template files. If you don’t understand those terms, please read the provided links. It will make sense once you do. I’ll be waiting.

Okay, now, I also mentioned plugin friendly. What does that mean? There are tons of plugins, and I mean tons of plugins. The way some plugins integrate with themes can be a hassle and there are several ways of doing that too. Some use a template tag, some use an action hook, a filter hook, and some use classes. What’s the best? The downside is I don’t have the exact answer but I can show you a quick way of making it easy for not only plugins but themes to take advantage of it. Using do_action and apply_filters.

Yes, WordPress has a great way of making sure that your theme does not create fatal errors. Using those two will not only make using child themes a lot friendlier for your users but plugins as well. Worse case scenario is that a plugin doesn’t use the right name for the hook or filter and it doesn’t work. Simple fix. Let’s make a quick example:

// somewhere in the header.php file
$col_count = absint( apply_filters( 'jc_column_count', 4 ) );
?>

<div class="col-<?php esc_attr( $col_count ); ?>">

What is super amazing is that a child theme or plugin can filter that. This was also mentioned a long time ago by Andrew Nacin. It is a great read and it does amaze me how many still haven’t adopted this.

The last bit I would like to go over is what may be a super important part for the user of a theme. The documentation. Yes, documentation. Even something so simple as how to set up a social menu can be tricky for a new person. When I say user I do mean both the developer and the site’s user. They may not always be the same person. Remember, you are thinking externally here.

I will always be a novice

I know it does sound funny to those that have known me for several years but that is how I view myself sometimes. I don’t mean that I am a beginner but I want to be one. I mean this in the most positive way I can think of.

A few years ago I was watching a documentary about the guitar. It opened my eyes to a slightly different way of thinking and looking at some things in my life. The person that really made me think most was Carlos Santana. Not too shocking since I fell in love with his guitar style of playing nearly a decade ago. He said that when plays the guitar he plays it like it’s his first time playing ( Or at least along those lines ).

This is often how I feel. The reason is because I think that there are several ways of doing one thing. Much like in PhotoShop there is more than one way of removing the background from an image. Yeah, each has their positive and negative but in the end they all get the same result. This is true when working with WordPress.

Recently I posted how to create a sticky post slider. I mentioned that another way of creating it would be to use get_posts rather than modifying the query. That is one way; another would be using query_posts and then of course there is what seems to be the more popular way of just getting a specific category or categories. There is nothing wrong with those methods. Each one has its own pitfalls and each one has their own feat. It is all a matter of preference.

What has brought this up is last week I was doing yet another WordPress theme review and saw a method that was new to me. It actually dealt with the WordPress theme customizer. It gave me an idea of how I could potentially use the customizer to include widgets or not. The other options was to display the copyright information on the footer.

Which then sparked an idea to create a plugin that has the ability to display the widgetized area on a single post or not, which actually could be attainable by using a simple conditional check for a theme option. And now I’m slowly trailing off.

The reason I say that I will always be a novice is because I want to be. It does sound a little odd to say but it is true. The reason is that I want to always be learning. The moment I feel like I have nothing left to learn that is when my brain wants to stop working and that is big no-no in my book. I want to always stimulate my brain and keep gathering information, methods and tons of new ideas.

The brain should always be focused and challenged on a daily basis.