WordPress is known for its flexibility, which is largely due to how it works with actions and filters. These are ways for developers to influence what is displayed where & how, or what operations to perform on certain moments or pages.
Our plugins include filters in key areas to give you further control over how the plugin functions or looks for your users. In most cases you’ll find a filter in our documentation, on a forum, or you’ll get it from a team member.
Caution: There is no ultra safe method to do these things. If you can just copy paste the code, you’ll usually be good. But if you need to make changes yourself and theres a risk of a typo, or if you accidentally missed a character when copy pasting, you can break your site. Of course when you know this you can take precautions, which will outline below.
There are 3 ways to add these code snippets to your site:
Code Snippets is a free and easy to use plugin that lets you add filters and actions fron your site backend without editing any files and also keep it organized and easy to manage. This doesn’t mean that you’re 100% safe from errors: if you make a copy paste error that breaks the code, it could still crash your site, but compared to using functions.php there are fewer things that can go wrong and it’s much easier.
Here’s how to add a filter or action to your site with Code Snippets:
The best way to prevent errors when placing a filter in your child theme’s functions.php is to:
Finally, a filter’s affect may not show up immediately because of WordPress’s caching. If you don’t see it, try closing and re-opening your tabs for that site, or opening the page in a different browser.
You may have noticed that in the above we were talking about child theme functions.php. This is because whenever your theme gets an update, WordPress will overwrite functions.php with a new version, and you’d lose your modifications. A child theme is basically a derivative of your main theme, in which you only specify what’s different to the main theme. Child themes never get updated! Read more about child themes here.