“Just add this snippet to your functions.php file to change that on your theme.” And a small shudder run down the store owner’s spine.
Here is a good example of a simple code snippet.
<?php //* Do NOT include the opening php tag //* Display author box on single posts add_filter( 'get_the_author_genesis_author_box_single', '__return_true' );
As a store owner you might have seen something like the above if you have ever:
Asked a question about your theme or plugin on a Facebook group and someone gives you a code snippet to help you do what you need to do.
Googled a question on how to do something with your WooCommerce store and the top ten results are posts ladened with long pieces of code that you can just drop into the appropriate file?
Code Can Be Scary
Over the years, I have heard many times from developers and designers that WordPress site and store owners should learn some code. Well, in a perfect world, maybe. But there are realties to face.
Code is scary stuff for a lot of people. It’s like a language you don’t understand. And if used improperly, it can raise havoc on your site.
Take for example, adding a code snippet to a theme’s function.php file. To be safe, you would download that file to your computer, make the change and then upload it. But for many people, this is easier said than done.
Or, worse yet, if you try, you might go to the dashboard, click on Appearance > Theme Editor and see this message.
Nothing better than this to get a lot of people’s hearts racing.
The Persistent Developer
Let me tell you a story.
Over the years I have written hundreds of tutorials on our site here. And almost never do I add code snippets. Why? Because I know my audience.
But a few years back, there was one developer who would not let it alone. I can’t tell you how many times I would do a post about a plugin and he would come in and say, “Why install another plugin when this simple snippet will work?”
Each time he left a comment like that, I would thank him for sharing but would also let him know that most of my readers do not want to mess with code and if I did suggest it, it would be in direct contradiction to the way I teach.
He never responded to my comments.
And yet he kept adding these kinds of comments on my posts.
The only way I could stop him was to finally delete or not approve his comments.
You might ask me why not leave them there for those who would know how to use them? Well, as I said, I knew my readers and I also knew what this could lead to problems with their site.
Never Assume. You Know What That Means?
Going back to my warning, actually, if you try to insert code and the code you add is incorrect syntax-wise, it won’t let you save any time.
Your Online Store Can’t Afford Intruders
That may sound harsh, but in reality, you need to keep your store up and running.
Imagine that you are in your brick-and-mortar shop. You sell televisions and you have wondered if there is a way to have them automatically change channels every couple of hours. So you Google it and you land on a video with this guy showing you how to rewire your connection to your cable feed with some wire splicing and extra wiring running from various television sets. But then you come across a digital gadget that you can plug into your cable and it automatically changes the channels. Which method do you feel more comfortable using?
There really are two main issues here.
You Site Goes Down or Sideways
Adding a snippet might take your site down. And if you added it through the theme editor, there is no way to remove it.
Remembering What You Did
The other issue here is if it all works perfectly, you may just pat yourself on your back. But what about when you need to remove the code snippet added to your theme? True, snippets can be labeled right in the code to explain what it does, but is the average store owner aware of this?
Or perhaps, someone else is now working on your site and you neglected to tell them what you did two years ago. Or you don’t remember yourself what you did? Or your theme updates. Or a number of other issues.
Snippets can be great, if you know what you are doing.
Just be careful. It’s that simple.