Safely Add Custom Code Snippet to Your WordPress Sites

Safely Add Custom Code Snippet to Your WordPress Sites

Often you need to add custom code snippet to your theme’s functions.php file or any specific plugin. And the biggest problem is that even a slight mistake can break your WordPress blog.

In this article, we will show you an easy way to embed code snippets to WordPress site so that you can prevent your site from being broken.

Often you get code snippet in WordPress tutorials so that you can improve the functions.php or plugin of your theme.

The problem is that even a small mistake in the custom code snippet can break your WordPress site and make it inactive.

And another problem is that if you add multiple custom PHP code snippets to a specific plugin in a site, then it becomes difficult to manage.

We will use Code Snippets plugin to resolve this problem and insert code snippet in WordPress site.

After activation, the plugin will add a new menu item with snippets labeled on your WordPress site. Clicking on it will show you a list of all custom code snippets saved on your site.

To add your first custom code snippet to your WordPress blog, click on “Add New” button.

it will redirect you to the ‘Add New Snippet‘ page.

In the given screenshot below, we have added a custom code snippet in code snippet editor to remove “Proudly Powered By WordPress” Link from the WordPress’s footer area.

Below the code box, you will see a text area to add a description. You can add anything here that will help you understand later What does this code do? where did you get it, and why are you adding it to your website and etc….

You can also specify the tag in your custom code snippet. With this, you will be able to sort your CSS code snippets based on topic and functionality.

Now, you can click on the ‘Save Changes and Activate‘ button.

If you want to save code snippet and do not want to activate it, you can click on ‘Save Changes‘ button.

Once insert snippet is saved and activated, it will immediately take effect on your site.

If you make a mistake in adding a custom code to your WordPress Blog, it will immediately make your site inaccessible and you will start seeing a syntax error or a 500 internal server error on your site. To fix this, you have to manually delete your codesnipet using the FTP client.

Code Snippets plugin provides an easy interface to manage custom WP code snippets in WordPress.

You can save add snippet to your site without activating custom code snippet. You can deactivate embed code snippets at any time. You can also export the custom codesnipet.

If you move your websites to another server, you can easily import all insert code snippet by visiting Snippets >> Import page.

If you use any other code snippet editor on your site, please tell us via comment.

If you like this article, please do not forget to share it on Twitter, Google+ and Facebook…..

Leave a Comment