Ad Code

Responsive Advertisement

Ticker

6/recent/ticker-posts

How to Add Code Snippets in WordPress

Want to add a custom code snippets into WordPress. In this post we will tell you how to do it.

Often you’ll find code snippets in WordPress tutorials with instructions to add them into your theme’s functions.php file or a site-specific plugin.
The problem is that even a tiny mistake in the custom code snippet can break your WordPress site and make it inaccessible.
The other problem is that if you add multiple code snippets in a site-specific plugin, then it can become hard to manage the file.
Recently while looking for a solution, we discovered an easy for users to add and manage custom code snippets in WordPress.

Adding Custom Code Snippets in WordPress

First thing you need to do is install and activate the Code Snippets plugin on your website. For more details, see our step by step guide on how to install a WordPress plugin.

Upon activation, the plugin will add a new menu item labeled Snippets into your WordPress admin bar. Clicking on it will show you a list of all the custom code snippets you have saved on your site.

Since you just installed the plugin, your list will be empty.
Go ahead and click on the Add New button to add your first custom code snippet in WordPress.




This will bring you to the ‘Add New Snippet’ page.
You need to start by entering a title for your custom code snippet. This could be anything that helps you identify the code. After that you can copy and paste your code snippet into the code box.


Below the code box, you will see a text area to add description. You can add anything here that helps you understand what this code does, where you found it, and why you are adding it to your website.



You can also assign tags to your code snippet. This will help you sort your code snippets by topic and functionality.

Finally, you can click on the ‘Save Changes and Activate’ button.
If you just want to save the code snippet and not activate it, then you can click on the ‘Save Changes’ button.

You can also change the scope of the code snippet. You can run it only in the WordPress admin area, on the front-end of your site, or everywhere. If you are unsure, then keep the default ‘Run snippet everywhere’ option checked.

Once you have saved and activated the code snippet, it would become effective on your site immediately.


We hope you liked this article.

Post a Comment

0 Comments

Ad Code

Responsive Advertisement