Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Invoke search/filter with url
- This topic has 8 replies, 2 voices, and was last updated 6 years, 8 months ago by
thenetking24.
-
AuthorPosts
-
August 29, 2019 at 2:56 pm #23846
thenetking24
ParticipantHey, thanks again for the great plugin and support!
Is there any way to pass some info through the URL to activate filters and/or search?
Kind of like:
/archive/?filter1=foo&search=barI attempted forcing something like this with JS after the page is loaded and noticed it may not have been responding well to that, is there any code examples for this?
Thanks again, keep up the great work!
August 30, 2019 at 9:08 am #23860Ernest Marcinko
KeymasterHi!
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 🙂
September 9, 2019 at 6:37 pm #23905thenetking24
ParticipantYou cannot access this content.
September 10, 2019 at 8:45 am #23911Ernest Marcinko
KeymasterYou cannot access this content.
September 11, 2019 at 8:11 pm #23929thenetking24
ParticipantThank you again.
Your jQuery test seems to be functioning and returning properly. I just now got a chance to disable all plugins other than yours and the custom post type CPTUI plugin. And I also removed all my .css and .js calls from functions.php in my custom theme based on BlankSlate or one of the other minimal empty wordpress theme packages. Your API & jQuery tests return the same thing no matter what plugins or scripts I do or do not have active.
I’m at a point where I can clone my theme into a new wordpress install/db and start fresh with your plugin. Let me know if there is anything I can look for before resorting to that, or in the process of rebuilding.
Thanks a million!
September 12, 2019 at 8:42 am #23935Ernest Marcinko
KeymasterHi,
I was able to check the site you linked, it was just online. The plugin version seems to be outdated. The console reports an older release number, from april 30, v4.15.2. If you update the plugin, clear the caches, then this issue should be resolved then.
September 17, 2019 at 3:06 pm #24013thenetking24
ParticipantI feel dumb.
Thank you for your attention to detail.
Best support I’ve seen for a plugin/script!
Thanks again man
September 18, 2019 at 8:49 am #24025Ernest Marcinko
KeymasterYou cannot access this content.
October 7, 2019 at 5:07 pm #24237thenetking24
ParticipantHey, sorry, I didn’t catch your last response. Yes, please close.
-
AuthorPosts
- The topic ‘Invoke search/filter with url’ is closed to new replies.