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

Issue with combining two searches and displaying the results

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Issue with combining two searches and displaying the results

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #42683
    deverrdeverr
    Participant

    Hi Support,

    I need your help properly setting up the search widgets on my page.

    I created a different set of searches for various pages and screen sizes and got an issue when using the main search widget in nav menu.

    Currently the way it is setup looks more or less like this (search name and it’s function) :
    1. Strona wyszukiwania zaawansowana desktop – Advanced search – used in results page (?s) – [wd_asp id=1]
    2. Menu Desktop Main – Main nav menu search – [wd_asp id=2]

    Advanced search works absolutely fine by itself, but the issue is with it’s integration with Menu Main search. When the user uses the search in Menu Desktop main search he is being redirected to the results page, but the results there do not refresh… I have to manually type in the phrase again in the advanced search bar to get it working. As you might imagine this is not very user intuitive and will cause a lot of issues in the long run.

    I use Elementor Pro on my website and uses your built-in feature to integrate with Elementor and the Results page (class = asp_es_1, etc.).

    I know that at this point you might say that the issue is that there are two different searches with two different IDs and refreshing the results might not work. Well, I also tried using just one search, Menu Desktop Main, setting asp_es_2 as main class to Elementor Post Widget on Results page and that still doesn’t help.

    Can you please have a look and let me know how can I fix that?

    My website’s details and versions:
    WP: 6.2
    Elementor Pro: 3.13.1
    Operating System: Linux
    Software: nginx/1.20.1
    MySQL version: Debian 11 v10.5.19
    PHP Version: 8.1.18
    PHP Memory Limit: 256M
    PHP Max Input Vars: 1000
    PHP Max Post Size: 99M

    I created an admin account on my site, so you can login and have a look, but PLEASE BE CAREFULL! THIS IS LIVE PRODUCTION WEBSITE! I don’t have a staging environment to use, so we have no choice, but to play on the main site.

    Awaiting your prompt reply and let me know if you will have any questions.

    Best regards,
    Patryk

    #42708
    Ernest MarcinkoErnest Marcinko
    Keymaster

    Hi,

    Thank you for the details!

    As long as the filters are identical on both instances, there is a way to force them to work together, but it involves a bit of custom code – nothing too fancy.

    Try adding this code via the Code Snippets or to the functions.php file in your theme/child theme directory – make sure to have a full server back-up first for safety. For more details you can check the safe coding guidelines.

    add_action('wp_footer', 'asp_change_query_args_for_compatibility');
    function asp_change_query_args_for_compatibility() {
    	?>
    	<script>
    	window.addEventListener('load', function () {
    		WPD.Hooks.addFilter('asp_redirect_url', function(url){
    			url = url.replace(/\?s\=(.*?)\&/, '?s=$1&asp_s=$1&');
    			return url.replace(
    				"p_asid=2", 
    				"p_asid=1"
    			);
    		}, 10);
    	});
    	</script>
    	<?php
    }

    This will force a trigger for the second search bar when a redirection is made throught the header search.

    #42719
    deverrdeverr
    Participant

    Thank you Ernest! This worked like charm 🙂

    Feel free to close this ticket.

    #42721
    Ernest MarcinkoErnest Marcinko
    Keymaster

    You cannot access this content.

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘Issue with combining two searches and displaying the results’ is closed to new replies.