How to Properly Add a Custom Code to your WordPress

How to Properly Add a Custom Code snippet to your WordPress

I noticed over the time that many site owners are not aware that improper custom code implementation can break an entire site. What usually happens is scenario where the site owner found some cool code snippet online and tried to manually add it to index.php (or some other) file. And of course a few minutes later, my phone is ringing because the site went down.

If you don’t have a tech knowledge and want to play around with custom WordPress features, the proper way add a custom code to your WordPress is by adding it your theme functions.php file. You can find this file in your theme directory. Log in to your hosting file, go to File Manager > Site Root directory > WP Content folder > Themes > Your active theme > Functions.php.

Before you do any changes, be sure to backup/download the functions.php file to your desktop so if anything goes wrong you can quickly re-upload it.

All the code you’re planning to add should be placed on the bottom of the file.  Once you add the code and hit the save button, preview the site and see is the feature you just added is functioning properly. If you’re getting any kind of error, open up functions.php and delete the code you added.  Errors may appear if the code is incompatible with your version of WordPress or if the code is not written properly.

If you accidentally delete one or more characters from within the original code snippet you’ll end up with errors or the site may become inaccessible.   In the most cases, adding the custom code to your WordPress is simple and safe thing to do because all changes could be easily reverted.

You can find many useful code snippets on Google, just type in the feature you’re looking for and include the word “custom code” or “functions.php”.

If you want to hire a WordPress Developer to do all the work for you, request a free quote on the homepage.