Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › search by categories to return subcategories
This topic contains 7 replies, has 2 voices, and was last updated by Ernest Marcinko 7 years, 2 months ago.
- AuthorPosts
- February 7, 2017 at 11:20 pm #11849
I want to type in a search term for a category to have the tool return the sub-categories. So if I type in housing, then apartments, condos, cabins should be returned. See these images:
https://gyazo.com/ea3f8bc19aeaf24ad57e64ec18b485ac
https://gyazo.com/27b017e56ef181d9cc82e9beb9685896
How do I do this ?
February 8, 2017 at 10:18 am #11852Hi,
This is only possible with a custom function that overrides the results after post processing. I’ve put together a possible solution for you. This function will go through the results and if finds child terms for the term, then it will replace them, otherwise leaves the original.
Please note that this is a customization request, which is not part of the support process, so I cannot guarantee this will work in all cases, always as excpected. Always have a back-up of everything, before editing any of your site fiels.
Place it into the functions.php file in your theme directory (copy from line 3):
It gave me positive results on a test environment, let’s hope it will work for you too.
Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
February 10, 2017 at 4:56 pm #11884Awesome thanks that worked perfectly !
Is there a way to direct that to a specific search instance ?
[wd_asp id=1] but not [wd_asp id=2] If I want #2 to return standard searching some where else on the site ?February 13, 2017 at 2:21 pm #11913Can you answer this request please ?
February 13, 2017 at 3:04 pm #11914Hi,
Actually, it is possible with a minor modification. This filter also passes the search ID as the second argument, so changing the code to this will help:
Change the $search_id variable to the search instance you want to affect only.
Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
February 13, 2017 at 3:34 pm #11915Thanks and do all the other searches then revert to the “standard” process of your search tool? By that I mean do the other searches ignore this special function and react according to how they are specifically built or do I have to somehow pass in a search key each time ?
February 13, 2017 at 3:45 pm #11916Never mind, I did some testing and it is working how I want it to … thanks for your custom help !
February 13, 2017 at 4:06 pm #11919You cannot access this content. Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
- AuthorPosts
The topic ‘search by categories to return subcategories’ is closed to new replies.