Custom code without hacking functions.php
So you want to add code to your wordpress theme but don’t want to mess directly with your functions.php file to make things more like you want. Adding some code in the form of a function to the “functions.php” file of your active theme is simple enough if you know what you’re doing but one extra } or / and the whole site will go down. The other issue with adding directly to your functions.php is when you change your theme that piece of code is no longer in effect and you need to code it again in the new theme.
So if you wish to have portability and ease of adding then it should be done via some kind of a plugin. So that the effect is persistent across themes. And the good news is, that there indeed are few plugins for the task.
1. Functionality Plugin
The Functionality Plugin is a sneaky little plugin that installs itself, and creates a “blank plugin” bearing the name of the site. It creates an option “Plugins > Edit functions” which takes the user to the editor page for the new blank plugin.
The user can add all custom functions inside this new blank plugin and it would run alongside the theme functions and other plugins. Simple and effective.
Pluginception is another simple plugin that is similar to the Functionality plugin but with some differences. It adds an option “Plugins > Create a New Plugin” where the user can create multiple new blank plugins and put code inside each of them.
The plugin can then be managed from the Plugins list and code inside these new plugins would work just like other plugins or functions inside functions.php
3. My Custom Functions
My Custom Functions creates a simple option “Appearance > Custom Functions” in the admin panel where you can type in any of your own php code/functions and it would take effect.
The plugin also ensures that the code is error free before applying it. So even if you code contains any syntax errors, you can fix it without having to get inside the file manager.
4. Code Snippets
The Code Snippets is a much more elaborate plugin that has provides the user with a user interface to create and manage multiple snippets each with a name and descriptions. The snippets can be deactivated when not needed.