Code Snippets WordPress plugin

With WordPress powering over 27% of the web, tutorials about the web’s most popular open source Content Management System abound.

Most code snippet tutorial blogs would present you with code to use in your theme’s functions.php file, to add some functionality to your WordPress theme.

While this may be easy to do even for newbies, adding code directly to your WordPress theme could be risky, and cumbersome, especially if you have to transfer files via FTP every time you add code snippets.

Adding code snippets directly to your theme’s functions.php ties the code to the theme. This means you loose the added functionality introduced by the code when you switch themes.

Additionally, when the added code introduces custom content or options, switching themes hurts data portability. You could end up with content in your database that your new theme cannot access and use.

Code Snippets is a plugin by Shea Bunge that allows you to add (and activate/deactivate) snippets to your theme without directly editing your active theme’s functions.php file.

The plugin adds a Graphical User Interface to your theme that allows you to add snippets to your theme. Code snippets are organised similar to posts that can be edited and activated/deactivated.

Code Snippets WordPress plugin

Code Snippets comes with options that allow you to set the colour scheme (theme) for the snippet editor and other settings enabling you to customise the code editor to your taste.

The plugin adds a new top-level menu item to the WordPress admin called Snippets. You may add a new snippet under Snippets -> Add New menu item.

Download, install and activate Code Snippets, and make sure to use this to add custom code to extend your theme, instead of editing your theme’s functions.php file directly.

Leave a comment

Your email address will not be published. Required fields are marked *