How trigger live search after Custom Code: automatically select filter values?

Home Forums Product Support Forums Ajax Search Pro for WordPress Support How trigger live search after Custom Code: automatically select filter values?

This topic contains 6 replies, has 2 voices, and was last updated by

11 months, 3 weeks ago.

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
  • #31400


    Dear Ernest

    Good plugin, amazing cheap price and it seems to have a great support (with you). I have checked several pages in this forum now, but couldn’t find an answer to my maybe rather simple question.

    I am constructing a website with an huge image database. I user Elementor PRO and Easy digital downloads (EDD). The EDD Downloads images have download_category and download_tag (…and ACF Custom Fields, but this is unimportant now). To display the Ajax search results I use the Elementor Pro Post Widget.

    I was able to set up an Ajax Search Pro Categories & Tag grid (without search bar) that works with the live search. But now I want to combine this with the classic wordpress Archive page for a single taxonomy. For example I want to write Blog articles with a artist name linked to a download_tag (artist name), so that users can directly jump from the Blog page to the the download-posts with a selection from all download-posts from this artist (download_tag) or download_category (for another example).

    A single download post of an image looks like this:

    You notice in the title header of the download the list with categories, which are linked, so the user can click them.
    Kopie Testdownload
    Kategorien: Bibel, Glaube, Spiritualität, Bibelfiguren / Charaktere der biblischen Geschichten, Charismen, Geistesgaben, Evodia (aus Philippi), Feiertage, Kirchengeschichte, Weihnachten

    Let’s say a user clicks this category: “Evodia (aus Philippi)”
    There is only one download-post with this category.

    He will be brought here:

    Please notice that you see TWO Elementor Pro Post Widgets. The one above is with Ajax Search Pro CSS (asp_es_1), so filtered. The post widget on the bottom is the normal elementor one that works with the regular taxonomy archive. So in the post widget below you see the WordPress search archive and in the post widget on top the Ajax Pro Results.

    I tried to make a research and was able to find this:

    With the help of the Code Snippets Plugin I was able to implement this custom code and it WORKS! The right category checkbox is selected, BUT the problem is that the page is not refreshing its live search. So I have to manually deselect and select the Category “Evodia (aus Philippi)” to make Ajax Search pro displaying the correct results.

    As I understand the problem Ajax Search Pro should trigger the Live search after processing the custom code. Am I right? I don’t know how to do this.

    I don’t think that you need this, but if you need to see the whole image database without any filters, it is here:

    I also read this and even tried to implement this code, but could not see any result (I added , download_category, download_tag to the $taxonomies):

    Thank you for your help!

    Kind regards from Switzerland, Luzern
    Dave Buettler



    Thank you very much for the details, it helps me a lot!

    I believe you have two options here:
    1. Is to add an empty search phrase query arguments to the end of the URLs, which will trigger the search: ?asp_s=
    For example:

    2. Enablign the auto-populate feature. This will trigger automatically on each page load, without needing the trigger URI.

    Ernest Marcinko

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



    Dear Ernest

    Thank you for your fast reply. It helped and it works now. I am happy. 🙂 I used the option 2: auto-populate. I hope I will not notice any negative

    For Option 1. I wouldn’t know how to add ?asp_s= to the custom code or the Ajax search instance.

    The only a bit negative detail is that you see the page refresh moment. The post widget shows first all images and then automatically refreshes to show the selected search results. This makes the user experience a bit slower and could look like a bug. But ok, I can live with that.

    But now let’s continue the user experience. The problem is now the URL. Is it possible to redirect from the Archive URL, Categories, Tags URL automatically to the main downloads-post URL?
    If Ajax Search Pro is handling all search results, it would make sense, that WordPress shows no category & tag archive URLs, but always just this base URL for all downloads-post types:

    Otherwise it will be somehow confusing if the user is watching the URL while selecting other taxonomies. It looks confusing because Ajax Search Pro takes over the WordPress Search results. So in functionality anything is fine, the user can deselect the “evodia-aus-philiippi” category and choose new categories or tags and Ajax Search Pro will show the correct results, but the URL looks strange, because it remains at the the first WordPress archive query. So the user will see search results that are the opposite of the URL. Some critical user with technical attention could think that there is something wrong and that they are missing some search results because of this wrong URL.

    This is not a very dramatic problem, I could live with this, but it would be nice if it is possible to solve. But I am not sure if this is a problem from Ajax Search Pro or I have to solve it differently.

    Thank you for your answer. 🙂


    That is unfortunately not possible at least not via the plugin. You may have to look into WordPress mod_rewrite rules or URL redirection rules. There might be a way to automatically direct queries to different URLs, but I don’t know if I recommend that at all. Changing URLs and resolving permalinks can cause a huge mess and may cause even more issues – speaking from personal experience.

    Ernest Marcinko

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



    That’s fine. I see, it’s not so easy and the problem is not existential. OK, so I will keep it like it is now. Thank you. 🙂

    Topic solved



    Dear Ernest

    A new DIFFICULT question about this topic: Is it possible to autoselect in a dynamic way ACF Custom Fields in a Search instance? I guess this is not possible?

    I have this Post Downloads Page here. In the red is the content of Custom fields about the product (e.g. color, black & white, transparency). This are all ACF custom fields from the post.

    Let’s say a user will click the first Custom field: “farbig” (Value of custom field). The Website redirects the user to the search results page. In the moment the clicked Custom field is not attached to the link and the user sees just all search results.

    Is it possible to pass some arguments (chosen custom fields) with the URL to autoselect the Custom Fields in the Search instance?

    I guess this is not possible and a workaround would be to create new taxonomies instead of custom fields?

    With categories & tags it works. If you click on the Post Downloads Product page (above) on one of this categories or tags, then WordPress redirects to a Archive Page and Ajax Search Pro is with the Custom Code (see postings above) able to autoselect the categories & tags.

    Post Tags & Categories
    Künstler: Hugentobler Hansi
    Kategorien: Bistum, Bistum Basel, Familie, Feiertage, Firmung, Jugendliche, Ort Location, Verlorenes Schaf (Parabel), Vom Kamel und dem Nadelöhr, Weihnachten

    I use Elementor Pro and EDD Easy Digital Downloads.

    Thank you & greetings from Switzerland, Luzern


    It is actually possible to preset the fields via this API call.

    In short:
    1. You open the developer console on the page, on most browsers it is the F12 button.
    2. Change the filter states however you want them – check/uncheck the checkboxes etc..
    3. Now, getting the state URI. Your search ID for that search bar is 1, so you type in to the console:

    ASP.api(1, 'getStateURL')

    and it will print out the page URL with some query arguments:
    4. Visiting that URL will preset the filters exactly as you changed them before. Use this for your desired button as the URL.
    5. You can repeat this proces as many times as you want with as many different variations you need.

    Ernest Marcinko

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

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

You must be logged in to reply to this topic.