If you are adding custom code for your WordPress site, such as code for a filter or action, its best to create a separate plugin just for that code. We recommend doing so as opposed to putting the code in functions.php for the following reasons:
- You can turn a plugin on and off easily to test.
- If you switch themes, even just to test something, you don’t lose your custom code.
- It’s simple.
To create a WordPress plugin, you just need to upload a file with a valid plugin header to your WordPress plugins directory. It can be this simple:
Here is are some background articles on hooks and custom code from our blog you might find useful: