Stop Writing Stupid Tutorials

I’m going to start you guys off with a quote today, signed the always excellent Konstantin Kovshenin:

Is it considered “cool” to copy/paste all my plugins into my theme’s functions.php file?

Now why would he write something like that? It is part of a paragraph (obviously) that makes fun of all these “paste this code into your theme’s functions.php file” tutorials out there. Sarcasm all around, and you all know how I love that shit. And irony, irony is also great fun. Ironing, not so much.

I’m sure I don’t need to tell you, dear reader who adore me more than anything in the whole wide (wild?) world, that filling your functions.php file with code you found using Google and a more or less accurate search query is a bad idea. You know this. You don’t put anything in functions.php unless it truly belong there.

Granted, not everyone agrees on what actually belongs in functions.php. There might even be a time when things that usually belongs in plugins makes more sense in functions.php, it would all depend on the project. I won’t condone such thinking in this column.

Also, I’m high on caffeine.

So you know that you shouldn’t post everything in functions.php, Kovshenin certainly knows it, and I’m pretty sure your grandma’s cat has a pretty good idea what features needs to be portable and what goes in functions.php too. We all know it, right? Right. Still, since Google will find this post and confuse the hell out of people, I’ll spell it out in two simple rules:

  1. Functionality that is entirely unique to your theme should be in your theme. That includes your theme’s functions.php file, obviously.
  2. Functionality that you would want to keep when changing themes should be in a plugin, since that wouldn’t disappear just because you activated a new theme.

Got it? Good.

Problem is, people who are writing WordPress tutorials doesn’t. And those tutorials will be published online, I hear this is the latest thing but wouldn’t know for sure since I’m submitting my column via a secretary who prints them out on a typewriter and send them via pigeons to wherever it is that this very site I’m apparently writing for is located. In fact, just last week I learned that you can find these words of mine on the internet. I thought this was a printed magazine, because surely that is something we need about a web publishing platform, right?

Actually, maybe we do. I just wouldn’t buy it. It would probably feature tutorials telling me to paste stupid code into my theme’s functions.php.

So, to conclude: Stop writing these stupid tutorials!

Shameless self-promotion: If you’re so inclined, I’m covering this in the third edition of Smashing WordPress: Beyond the Blog.

Photo credit: Daniel Finnerty (CC)

Comments (2)

  1. I understand what you are saying, to a point. I also agree that what can/should be included in a themes functions.php file is totally still up in the air.

    However, you give us an order to stop writing these tutorials, but you need to propose a superior solution.

    I would suggest functionality plugins, BUT it is easier for me to tell a person to add the code to my themes functions.php file, than it is to add the code to a functionality plugin, especially since I don’t know what they called the plugin, what their plugin files are named.

    I find that often people don’t have a functionality plugin, and to explain to them they need to create a plugin file, add the code, compress and upload, or upload via FTP, requires extra explaining, and more likely confusion than simply adding to a themes functions.php file.

    • Of course it is easier for you to suggest to your readers that they can just copy-paste the code to a functions.php file. That’s not an excuse however, it’s like suggesting they don’t bother with validation because it is easier not to.

      Do things right, and teach your readers the same. That will make the web a better place.

Participate