- December 14, 2017 at 11:26 am #15890
I am looking for a way to change the type of search at run time, so the user will have an option to select:
Either search by category, Or
Search by name
Is there a filter or an action I can hook to change the search form behaviour?
Thank you so much for your kind help.
Yaniv.December 15, 2017 at 7:23 am #15894
Well, currently there is no front-end selector for enabling/disabling the search in taxonomy terms, but there are ones for choosing to search in title/content – so maybe I can suggest a possible setup and a small code snippet to covert those selectors for title/category.
I have made a test setup, that displays a drop-down filter of the ‘Search in title’ and ‘Search in content’ selectors, and the ‘Search in content’ selector is converted to a term only search via a small code snippet:
1. Use this setup on the front-end options panel: https://i.imgur.com/SQNnbiz.png
2. Add this custom code to the functions.php in your theme/child theme directory (copy from line 3 only!). Before editing, please make sure to have a full site back-up just in case!
This should do the trick, or at least help you get to the right direction.Best,
If you like my products, don't forget to rate them on codecanyon :)
You must be logged in to reply to this topic.