search by categories to return subcategories

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 Ernest Marcinko 7 years, 2 months ago.

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #11849
    petermac
    petermac
    Participant

    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 ?

    #11852
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi,

    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 :)


    #11884
    petermac
    petermac
    Participant

    Awesome 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 ?

    #11913
    petermac
    petermac
    Participant

    Can you answer this request please ?

    #11914
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi,

    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 :)


    #11915
    petermac
    petermac
    Participant

    Thanks 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 ?

    #11916
    petermac
    petermac
    Participant

    Never mind, I did some testing and it is working how I want it to … thanks for your custom help !

    #11919
    Ernest Marcinko
    Ernest Marcinko
    Keymaster
    You cannot access this content. Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


Viewing 8 posts - 1 through 8 (of 8 total)

The topic ‘search by categories to return subcategories’ is closed to new replies.