WordPress Facebook groups are awesome. Just search for “WordPress,” “Elegant Themes,” or “Divi” and the groups that pop up will astound you. One of the biggest questions from beginner users all the way to advanced ones seems to boil down to What’s the best plugin to do X, and every time, there are dozens of responses with suggestions. And that’s great.
But the issue that this question skips over is how can I do X with WordPress, which is not a plugin question. It is a code question. All WordPress plugins are just packaged bits of code that you plug in (hence the name) to the main WP backend. Some plugins like the Divi Builder add major functionality that expand the bounds of what’s possible with the core. But many are minimal snippets of PHP that accomplish a single task that users could implement on their own.
So I guess the question I need to answer then is, when should you use code snippets vs plugins? So here are some things to consider.
How Much is Your Time Worth?
A big reason folks come to WordPress over other CMS platforms or blogging software is because of the rich plugin ecosphere. A plugin exists for pretty much every situation that a WP user could potentially come across, from SEO to page building to accepting payments to making child themes and so on. And with just a few mouse clicks and tap-tap-taps on the keyboard, voila…problem solved/new feature added.
When your time is limited (or your client’s budget is), you have to cut a few corners or make your decisions based on that. If you have a same-day deadline to get a fix on a major site and you can do that with a plugin vs a code snippet in functions.php, you’re going to go for the plugin every time. We’ve all done that.
Time really is money, and plugins are quick. So a lot of designers and developers have a stable of standard plugins they install that helps them keep clients happy and the turnaround for new sites and jobs far quicker than if they were hand-coding things for every single client.
You need to gauge the ROI on your work, just as with everything else.
Consider the Long Term Effects
As quick and easy as installing a plugin can be, you also have to consider the long-term life of your site. What might look like a panacea right now might turn into a headache that might later turn into a migraine.
WordPress is always changing. If the plugin code doesn’t, too, they can easily become obsolete. If the developers abandon a project or are slow to update, you could lose some basic functionality. The scary part is that you might have no idea as to when you might get it back. (And that can cost oodles of revenue and profits.)
Most importantly, if you use a plugin to solve a problem that is just as easily solved with a code snippet, you avoid potential issues with the plugin.
For instance, I’ve seen people use a plugin to remove the sidebar on posts and pages. In effect, all that plugin does is edit your single.php file. You can open it up, remove a single line to accomplish the same thing.
< ?php get_sidebar(); ?>
Isn’t that better than keeping a plugin installed for years?
Do You Trust The Developer?
There are millions of plugins available for free when you hit the repo. And I would trust a minuscule fraction of them on any site I or a client runs.
Because I don’t know who in the world put that thing together. I don’t know how good they are at coding. I don’t know how efficient they are with updates or how well their code interacts with the WordPress database. Maybe their code makes twice the number of queries it should for any given action. I don’t know. But I know what my code will do when I write it.
You also have the issue that the developers might just stop supporting the plugin. As it ages, it may become incompatible and force you to find another solution to your problem. That is time which equates to lost revenue. And lost productivity because you’re re-solving a problem that already had a solution.
Using your own code snippets helps avoid this pitfall. You still have to maintain the code additions. (Which is specifically why you should be using child themes.) You will know what, where, and why changes were made. You’d know how to update the code snippets you added, and most importantly, you would be in control of the whole process yourself.
Plus, if you’re directly editing the PHP files that come with WordPress, you’re likely adjusting base functionality that won’t be changing much, while plugin APIs and interactions will. Think about the havoc that might be wreaked if the get_sidebar() function gets changed even a little and that plugin doesn’t?
Trusted Developers are Amazing, Though
When you do find a plugin developer whose work you trust, they can save you a lot of headache. For instance, I often use a plugin that installs and activates child themes in just a few clicks. I can then delete the plugin from my site.
That is a lot quicker than installing a child theme manually. I know it doesn’t leave behind weird stuff, so I trust it. These situations are why plugins exist. They are designed to make your life and website better, not replace your expertise.
I had a professor in graduate school tell me once that “you have to know the rules before you’re allowed to break them.” You can look at plugins the same way. They’re for time-saving, not job-doing.
Do You Have Access to WordPress Files?
A major factor in whether or not to use code snippets vs plugins has to do with how much access to the file system you have. To add code snippets into the WordPress core files, you need FTP access (or at the very least cPanel credentials). Some companies and clients don’t give that out. In some cases, clients may not know how.
If you are locked out of the files, you really have no choice but to use plugins.
And if they’re keeping things on lockdown, voluntarily or not, plugins will be how they generally want to interact with the software. Using plugins makes problem solving easier. (Stop me if you’ve heard this one: “start by disabling all your plugins…”)
Changing the core files with code snippets or custom code isn’t something a lot of end users want to deal with. I have personally been told by clients that under no circumstances did they want custom code, even CSS, and to do everything in the theme options and customizer. That was fun.
How Much Code Do You Know/Want to Know?
I mean, I couldn’t edit a page written in Spanish despite being okay at words in English. Folks who don’t know the languages can’t change what the code does.
But here’s my question to you: how much do you want/need to know?
Digging into the WordPress core files is the single best way to learn the system I know of. You can read tutorials and documentation all day long, but there’s still no replacement for getting in there and editing functions.php yourself.
If you have no desire or your career trajectory isn’t going to be helped by learning the code you’d need to replace plugins, then by all means, plug it in, plug it in. There’s no reason not to.
But if your future relies in any way on understanding the inner workings of WordPress, trying to implement solutions without plugins is a great way to ease into unfamiliar territory.
For example, I learned how to read and edit single.php by needing to move where the title appears on the page. Plugins can do that easily. But it turns out, so can HTML (with a basic PHP function baked in).
<h1 class="entry-title">< ?php the_title(); /></h1>
Doing something as simple as rearranging that one line of code in single.php can be the gateway to being able to adjust code snippets all over the WP core in lieu of plugins. And that snowballs into more confidence and ability, which directly relates to knowing when it’s better to use a plugin than code it yourself.
A Good Rule of Thumb
I follow a life-changing piece of advice I learned from a podcast: if a task takes 1 minute or less, do it immediately instead of putting it off. You can kind of adapt that to WordPress code snippets vs plugins, too: if writing a code snippet takes as much or less time than installing and configuring a plugin, just write the code.
Of course, you have to weigh that decision based on how much code you know and intend to learn overall. In the end, that approach has made me far more knowledgable of WordPress, PHP, and the entire plugin ecosystem. I think the same thing will happen to you, too.
So next time you hit the plugin repo, pause for a second. Ask yourself, “could I do this with code?” And if the answer is “yes,” follow that up with a “but is it worth it?”
Then you’ll have your answer to the age old “code snippets vs plugins” debate.
What makes you decide whether to use code snippets vs plugins?
Article thumbnail by hanss / shutterstock.com