How to get Woodmart search action
-
Hello,
I am registering all searches in my site just to keep control with what people are looking for. But as far as i have figured out the standard GET does not work unless users click enter during their search.
if ( isset( $_GET['s'] ) ) {
Is it somehow possible to catch up with the ajax search used by Woodmart?
Brgds
Rune
Also, how can i get the below code included with ajax search, if possible?
function afas_search_filter( $query ) {
if ( $query->is_search && ! is_admin() ) {
$string = strtolower( get_query_var('s') );
switch ( $string ) {
case 'nødteppe':
$string = esc_attr( 'hypotermi' );
break;
case 'røksyre':
$string = esc_attr( 'røyksyre' );
break;
default:
$string = esc_attr( $string );
}
$query->set( 's', $string );
}
}
add_filter( 'pre_get_posts','afas_search_filter', 9 );
function afas_search_function( $search_term ) {
if ( $search_term ) {
switch ( $search_term ) {
case 'hypotermi':
$search_term = esc_attr( 'nødteppe' );
break;
case 'røyksyre':
$search_term = esc_attr( 'røksyre' );
break;
default:
$search_term = esc_attr( $search_term );
}
}
return $search_term;
}
add_filter( 'get_search_query', 'afas_search_function' );
Or is there another way to set synonyms, replace the search term?
I have used relevanssi before but it is so very slow. The search now is more instant without relevanssi.
Brgds
Rune
Hello,
WoodMart theme support does not cover such kind of customization, please try to find a developer who would help you.
Best Regards