Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Search phrases aren't triggering search in search bar › Reply To: Search phrases aren't triggering search in search bar
November 26, 2021 at 1:54 pm
#35759
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.