How to Easily Add Custom Code Snippets in WordPress


How to Easily Add Custom Code in WordPress (without Breaking Your Site)
Sara Romero

Would the code entered into this plugin persist through theme updates? Here’s what I’d like this plugin to do: In order to have the year update automatically in the copyright, many developers place a snippet of php code into a child theme to accomplish this. I really don’t want to make a child theme for every website just for that tiny change, but the alternative is to have my changes disappear with each theme update. But adding a child theme for something so minor seems like building a whole new fence when all you want to do is change the color of the latch on the gate. Maybe this plugin is the easy way to do this?

WordPress.org
Mildred Sherman

A snippet is a small chunk of PHP code that you can use to extend the functionality of a WordPress-powered website; essentially a mini-plugin with less load on your site.
Most snippet-hosting sites tell you to add snippet code to your active theme’s functions.php file, which can get rather long and messy after a while.
Code Snippets changes that by providing a GUI interface for adding snippets and actually running them on your site just as if they were in your theme’s functions.php file.

How to Correctly Add Custom Code in WordPress
Bonnie Jenkins

You can repeat these steps as many times as you need to add custom code in WordPress. This is what will have happened if you inserted all of the code correctly, but let’s say you inserted the code wrong and you clicked the “Save Changes and Activate” button. You would see this error message. It is very helpful because it points the exact line the error occurs. Simply hit the back button and fix the code.

Be the first to comment

Leave a Reply

Your email address will not be published.


*