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.