Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Live Search doesn't close after result click › Reply To: Live Search doesn't close after result click
February 9, 2023 at 2:51 pm
#41290
Keymaster
Hi,
It is intended behavior, as the redirection itself will clear the window anyways. In your case the issue is, that the integrated top bar closes (containing the search bar) so the results are left on the page.
You can get by this very easily via a small custom code snippet. 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', 'asp_add_footer_script', 99999);
function asp_add_footer_script() {
?>
<script>
jQuery(function($){
jQuery('body').on('click', '.asp_r .item', function(){
ASP.api(1, 'closeResults');
});
});
</script>
<?php
}
This will trigger a results closing event upon the click, before redirection.