Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Invoke search/filter with url › Reply To: Invoke search/filter with url
Hi!
Thank you for your kind words!
Actually, there is a way, it requires some work, but it is possible. Triggering the search is simple, you can read about it here. Presetting the filters is a bit more complicated, as the filters state URL is required, and it can be requested via the plugin API.
For that, you need to open your browser developer console, and enter this API method there:
ASP.api(1, 'getStateURL')
Change the number ‘1’ to the search ID you have, in case it is different. This should print out a URL like so: https://i.imgur.com/prUknH6.png
That is the URL of the current filter states on the current page. If you change the filters on the current page, and execute the above code again, it will print out those states. Visiting that URL will automatically preset the filters to the given state.
Now, to trigger the search with the filter state URL, you need to append the ‘asp_s’ query variable to it as well with the given phrase. For example, if the getStateURL returns something like this:
https://ajaxsearchpro.com/?p_asid=1&p_asp_data=.....
..then just append the query variable after the p_asid query variable, like so:
https://ajaxsearchpro.com/?p_asid=1&asp_s=my phrase&p_asp_data=.....
..and that’s it 🙂