Full stack web developer, interested in all the things, but especially the web, code, design, Linux, OS X, PHP, WordPress, JavaScript & robots.

WordPress Theme Function, or Plugin?

It’s been 2 months since I started on my 10,000 hours of WordPress development. I’m not sure how many hours I’ve devoted to WordPress development in those 2 months (I’ll need to figure out a formula at some point), but it’s definitely a good few. I would estimate it in the hundreds, easily, maybe.

Many of those hours have been spent reading the WordPress Codex. The Codex has become like my best friend, I visit it daily and rely on its advice. I’m sure the popularity of WordPress is in no small part due to the quality of the documentation available on the Codex. It really is very good.

One thing that I’m learning, not from the Codex, but through trial and error, is when to develop a feature as a plugin, instead of a theme function. I guess I went into this not knowing how long it would last, or how many WordPress installations I would be able to work on, so when I started working on the theme for this site, I used the theme’s functions.php file for everything. I now know this was an error.

At my day job, I’ve got the opportunity to work on a number of WordPress sites and like most developers, I don’t like writing code twice. So, the first rule of thumb from this point on is, if a feature can be used on more than one website, regardless of how trivial it is, make it a plugin.

The second rule of thumb, if the feature is not related to style or presentation, make it a plugin.

These rules are no doubt old news to seasoned WordPress developers, but if you’re just starting out, or like me, you’re prone to bouts of muppetry, they might be worth some consideration.

Leave a comment

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