Resolving Action/Filter Conflicts in Plugins or Themes

Last updated December 18, 2018 « Knowledge Base

It is important to note that these actions/filters are perfectly acceptable to use in most cases. You must evaluate whether the resulting function call is causing a conflict with SearchWP by making changes that may be adversely affecting search results pages. If you are seeing this notice but are not experiencing any issues with SearchWP, you can feel free to dismiss them via the More info link.

SearchWP aims to be a turnkey solution, simply hijacking WordPress native search instead of requiring that you make certain code-based changes in your theme or elsewhere. Unfortunately plugins and themes sometimes perform the same action on search pages and in doing so reverse the work SearchWP has done, often resulting in unchanging search results or even worse: no search results at all. SearchWP aims to check for potential conflicts like these, and if any are found you are presented with a notification in the WordPress administration area:

filter-conflict

This alert alone may give you enough information to remove the offending filter, but if not you can toggle the More info link to find out exactly which functions may be interfering with SearchWP:

filter-conflict-expanded

If you are experiencing issues with SearchWP and are shown one or more of these notices in your WordPress administration area, there is likely a Filter conflict that needs to be resolved.

Using the information provided in the notice details, you should first check for any files in your active theme making use of these filters that match the function information outlined in the details. These hooks are usually found in your theme’s functions.php or one of the framework includes (if your theme was built on a framework). If you purchased your theme from a third party you can also inquire with them about the filters they are using, passing along the information provided by SearchWP.

Once you have located the offending hook, you should analyze the code to see if it is modifying queries run on search results pages. If so, you should use WordPress’ remove_filter function to disable the filter. Alternatively you could just comment out the add_filter line, but editing third party theme files directly isn’t recommended as the edits will be overwritten during subsequent theme updates. Instead you should create a Child Theme and use remove_filter to resolve the issue.

Fixing filter conflicts in plugins

If you have reviewed your theme code (both child and parent) and not found any hooks that are causing issues, it is likely a plugin causing the problem. Plugins carry with them a lot of code, so it is recommended to first deactivate all plugins except SearchWP. Upon doing so the notices will be removed. Begin re-activating plugins one at a time until the notice appears again. When it does, you can begin sifting through the hooks utilized in the most recently activated plugin to determine if there is an actual conflict.

As stated above, usage of filters that cause these warnings to appear are perfectly acceptable, and if you are not seeing any issues with SearchWP, you can dismiss the notices, as they are just a precautionary note.

Continue activating your plugins until they are all active again, checking for (and removing) any problematic hooks affecting search results pages. If you are not sure whether a particular hook in your theme or plugin may be causing issues with SearchWP, please feel free to create a gist at https://gist.github.com and submit it along with a support ticket.

Fix Search on Your Site. No Coding Required!

Now you can utilize all of the content that's gone unrecognized by native WordPress search instantly with SearchWP

Get SearchWP