This website uses cookies to personalize your experience. By using this website you agree to our cookie policy.

Cannot override Search Results page

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Cannot override Search Results page

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #57580
    cpunter_e8TMcpunter_e8TM
    Participant

    Hi,

    I have followed the doc here, but I cannot get it worked.
    https://documentation.ajaxsearchpro.com/behavior/results-page-override

    I’d like the flow like this: when users click or enter search on the default search forms (anywhere on site), instead of going to default search result page, they will be redirect to the custom search results page where I already put the ASP shortcode.
    https://www.hifi-advice.com/blog/prometheus/?page_id=42842

    Thanks in advance!

    Best,
    George

    #57581
    Ernest MarcinkoErnest Marcinko
    Keymaster

    Hi George,

    It is possible, but you will have to programmatically edit the default search forms to redirect to that URL. That is outside of the scope of Ajax Search Pro though, the default search forms are not controlled by the plugin.

    Because that I can’t guarantee anything as this is way beyond my support duties, but I’m still happy to help.

    The best way to do that is to edit the default search forms source code and add a hidden input with the page id and change the “s” input to “asp_s” to auto-trigger the search on your custom page.

    So this is the original header form:

    <form method="get" action="https://www.hifi-advice.com/blog/prometheus">
    	<input type="text" name="s" class="input-search font-1 active-true" placeholder="Search">
    	<input type="hidden" name="post_type" value="post">
    </form>

    And changing it to:

    <form method="get" action="https://www.hifi-advice.com/blog/prometheus">
    	<input type="text" name="asp_s" class="input-search font-1 active-true" placeholder="Search">
    	<input type="hidden" name="page_id" value="42842">
    </form>

    will do the trick.

    If it is not possible to change the source code for some reason, then using a javacscript code snippet could also work:

    document.querySelector('.cactus-form-header form')?.addEventListener('submit', function(e) {
      e.preventDefault();
      var s = encodeURIComponent(this.querySelector('input[name="s"]').value);
      window.location.href = '/blog/prometheus/?page_id=42842&asp_s=' + s;
    });

    However these heavily depends on implementation. You may also have to consult with the theme developer on how to change those parameters properly.

    #57584
    cpunter_e8TMcpunter_e8TM
    Participant

    Hi,

    Thanks for your quick support.

    Yes, if it requires additional code, I’ll find a way to implement it. However, in which scenario would the plugin’s feature called “results page override” as mentioned in the provided documentation be utilized?

    Best,
    George

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.