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

Reply To: Reset categories when using the search field

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Reset categories when using the search field Reply To: Reset categories when using the search field

#40129
Ernest MarcinkoErnest Marcinko
Keymaster

Hi,

Well, actually this might be possible via a minor custom code snippet. There is an API function to reset the filters, so ideally I would trigger that when the search input gets focused.

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_footer_custom_script', 999999);
function asp_footer_custom_script() {
	?>
	<script>
	document.querySelectorAll('input.orig').forEach(function(el){
		el.addEventListener('focus', function(){
			ASP.api(el.closest('.asp_m').dataset['id'], 'resetSearchFilters');
		});
	});
	</script>
	<?php
}