• Resolved Rafael

    (@jordh)


    Hello,

    I am having issues with the search function on my homepage that runs a woocommerce shop. Whenever a search term with no results is entered on a product page (the search field is in the site’s header), a 404 page is returned instead of the usual “No results found” message. This happens in both AWS and standard WordPress searches.

    While this problem isn’t specific to AWS, I want to circumvent it in AWS by always using my site’s home_url as the url for search results (e.g. “www.foo.com/?s=bar&type_aws=true”), regardless of which page the search has been submitted from.

    I have looked into the plugin’s php files, but I did not find a way to modify the search result URL to always be based on the home_url.

    Any help is appreciated.

    Regards,
    Rafael

    • This topic was modified 6 years, 3 months ago by Rafael.
    • This topic was modified 6 years, 3 months ago by Rafael. Reason: Fixed typos
Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter Rafael

    (@jordh)

    I was able to fix the issue. As it turned out, the culprit was a piece of code by a previous developer in the header.php (that includes the search field). Wrapping the whole AWS field was a form tag like this one:

    <form action="" class="searchform" id="searchform" method="get" role="search">

    Because of the empty action attribute, the search form would always use the current page URL to attach the search query to. I circumvented this by specifying the action attribute like this:

    <form action="<?php echo home_url( '/' ); ?>" class="searchform" id="searchform" method="get" role="search">

    Now the search always loads the site’s base URL instead of the current page URL to attatch the query to.

    Plugin Author ILLID

    (@mihail-barinov)

    Hello,

    Thanks for letting me know about this.

    For now AWS search form already use home_url() function for form action value.

    Thanks.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Always use home_url as search URL’ is closed to new replies.