Custom redirect with filters applied

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Custom redirect with filters applied

This topic contains 2 replies, has 2 voices, and was last updated by jmjones328650 jmjones328650 4 years, 3 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • #26883

    Hi Ernest,

    Another couple of questions regarding my set up.

    1. On the landing page there is a search bar that redirects to the search page – currently, when I apply filters on the search on the landing-page, they aren’t being applies on the search page. Is there something I need to do in order to resolve this?

    2. On my landing page I am querying three custom post types (alerts, news and insight). I would like to place a ‘view more’ link next to the respective section. This link would take the user to the search page and display all the posts associated with that respective custom post type – is there a URL string that I would need to put into my ‘a’ tags to achieve this?

    Thanks again for your help!


    Ernest Marcinko
    Ernest Marcinko

    Hi Joe,

    A. That only works when the same search instance shortcode (ID) is used on both pages. So if you have a different search on one page, and another on the search page, it won’t parse the filter values, as it is a different one.

    B. This is a bit more complicated, but doable. I am copying an answer from a different thread below, with the istructions. First, you need to navigate to the search results page, as you need the URL for that serach bar.

    There is an API call, that can give you the ‘state URL’ of the current search, which is basically what you are looking for. This state URL can be requested via the javascript console.

    To get a URL to a specific search state, do the following:
    1. Set up the search filters as you need them. In this example I have selected the following filters:

    2. Open your developer console. In Google Chrome browsers you need to hit the F12 button once, and a window will open on the bottom of the browser window. Make sure to navigate to the ‘console’ tab there, it should look like this:

    3. Now, enter the following code to the console input (I’m assuming the search ID on the results page is still 3):

    ASP.api(3, 1, ‘getStateURL’);
    ..and then hit the enter key to execute it. It should return something like this:

    4. That is the state URL of the current search filters and input. You can right click to copy it. Using that URL will open the same exact page with these exact filters selected.
    In my case this URL was exactly this.

    You can use this method to generate any states, then copy the URLs. If you visit these URLs the search is re-created with the filters and the search phrase chosen.

    Ernest Marcinko

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


    Works perfectly!

    Thanks for that Ernest. As for the first issue, I will make do and just remove the filter option.

    Thanks again! Have a great day.

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

You must be logged in to reply to this topic.