Custom Snippets Plugin

You’ve probably seen WordPress tutorials on the internet that either have “without a plugin!” in the title or tell you to stick the code snippets into your functions.php file.

You shouldn’t do this. Code snippets should always find a home in a plugin, and I’ve created that special plugin just for you!

Enter the Custom Snippets Plugin.

Click Here to Download the Custom Snippets Plugin

Every code snippet, big or small, that is on this site (unless otherwise specified) should go inside of this plugin that I have created for you. People will tell you (and I have been guilty of this in the past) to avoid using plugins and to just stick the code in your functions.php file. There are 3 main reasons why you DO NOT want to place code in your functions.php file:

  1. Your functions.php file is inextricably tied to your theme. If you decide to change themes but have placed code in previous theme’s functions.php file that is theme agnostic (meaning it can be used with any theme), then you are in for a rude awakening when things stop working after switching themes.
  2. Myth busted – PLUGINS DO NOT SLOW YOUR WEBSITE DOWN. Only poorly coded plugins slow your website down. Plugins are run in the same manner that the functions.php file is run, so it literally makes no speed difference whether you place code in a plugin or the functions.php file.
  3. Plugins provide you with an automatic failsafe in case your code contains a parse error. Plugins check to see if the code will render the white screen of death, and if it does, it stops the plugin from activating and let’s you know where the error occurred so you can fix it. The functions.php file does not do this and will render your site useless until you fix the error.

The list could go on, but these reasons should be enough to convince you that plugins are the way to go when you want to add custom code snippets into your website.

Click Here to Download the Custom Snippets Plugin

Instructions for Using the Plugin

  1. Click on the link above to download the plugin.
  2. Navigate to your Plugins page for your WordPress install (Dashboard > Plugins).
  3. Click on the “Add New” button beside the Plugins page title.
  4. Click on the “Upload” tab just below the Plugins page title.
  5. Upload the zip file you just downloaded and click “Install Now”.
  6. Once the plugin is installed, click on the “Activate Plugin” link to activate the plugin.
  7. When adding custom snippets, make sure to place them between the two comment blocks inside the plugin. The code below the comment blocks ensures that your custom plugin doesn’t accidentally get updated if a plugin in the WordPress repository has the same name and slug.

Again, when adding the custom snippets to your plugin, make sure you add them between the two comment blocks inside the main plugin file. This will keep all of your code snippets in check and keep you from accidentally deleting or removing something important from the plugin itself.

If you have existing code snippets in your current functions.php file, go ahead and move them over to this custom snippets plugin. Save yourself the trouble (and potential heartache) of doing it later and migrate all of your custom snippets to this plugin.

It’s as easy as that. Now you have a reliable, fool-proof way of adding custom code to your WordPress website without having to worry about switching themes, speed or breaking your site when you do something wrong.