Search phrases aren't triggering search in search bar

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Search phrases aren't triggering search in search bar

This topic contains 7 replies, has 2 voices, and was last updated by Ernest Marcinko Ernest Marcinko 5 months ago.

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #35752
    deinurlaubsdeal
    deinurlaubsdeal
    Participant

    Hi,

    I’ve attached credentials for my staging evironment which is exactly same as my live site.

    If you look here: https://staging-deinurlaubsdeal.kinsta.cloud/reisedeals/ (live site: https://dein-urlaubsdeal.de/reisedeals/) you will see your search bar on the right side. Also, there are some search phrases beneth which usually trigger the search above when clicked. Since some weeks this is not working anymore.

    The search bar on the homepage is working fine: https://staging-deinurlaubsdeal.kinsta.cloud/ (live site: https://dein-urlaubsdeal.de/).

    I already reached out to the support of WPRocket and Perfmatters since these plugins could be having an conflict, but both support teams told me, there is no problem on their side. So could you please take a look and fix this issue?

    Thanks
    Caio

    #35759
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi,

    It looks like some sort of a minor script conflict to me. The search triggers, but it is immediately cancelled.

    Try adding this code 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', 'my_custom_wp_footer');
    function my_custom_wp_footer() {
    	?>
    	<script>
    	(function($){
    		"use strict";
    		// Top and latest searches widget
    		$(".ajaxsearchprotop").each(function () {
    			let params = JSON.parse( $(this).data("aspdata") ),
    				id = params.id;
    
    			if (params.action == 0) {
    				$('a', $(this)).on('click', function (e) {
    					e.preventDefault();
    				});
    			} else if (params.action == 2) {
    				$('a', $(this)).on('click', function (e) {
    					e.preventDefault();
    					ASP.api(id, 'searchFor', $(this).html());
    					$('html').animate({
    							scrollTop: $('div[id*=ajaxsearchpro' + id + '_]').first().offset().top - 40
    					}, 500);
    				});
    			} else if (params.action == 1) {
    				$('a', $(this)).on('click', function (e) {
    					if ( ASP.api(id, 'exists') ) {
    						e.preventDefault();
    						return ASP.api(id, 'searchRedirect', $(this).html());
    					}
    				});
    			}
    		});
    	})(WPD.dom);
    	</script>
    	<?php
    }

    If all goes well, it should resolve the issue. I will look into this in more details on our test servers.

    Best,
    Ernest Marcinko

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


    #35956
    deinurlaubsdeal
    deinurlaubsdeal
    Participant
    You cannot access this content.
    #35959
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Can you please update to the latest plugin version (4.21.8)? Then try without the code, it may resolve the issue, I remember making changes around that code in the previous release.

    Best,
    Ernest Marcinko

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


    #35963
    deinurlaubsdeal
    deinurlaubsdeal
    Participant

    I’ve already updated the plugin on the live site and tried without the code, still the same issue…

    #35966
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Can you please try swtiching the javascript source option to “minified” here: https://i.imgur.com/RB2eEt9.png

    Best,
    Ernest Marcinko

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


    #35977
    deinurlaubsdeal
    deinurlaubsdeal
    Participant

    This worked out, thanks!

    #35985
    Ernest Marcinko
    Ernest Marcinko
    Keymaster
    You cannot access this content. Best,
    Ernest Marcinko

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


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

You must be logged in to reply to this topic.