How to modify posts_where filter only for the search query
I'm using posts_where filter in order to modify the user searches on a web, but i find out that some default widgets like the "more recent posts" uses this filter too and their behaviour are also modified. I am trying to find a way to avoid that anything other than the users searches use the posts_where filter.
This is my code:
add_filter( 'posts_where' , 'posts_where_statement' );
function posts_where_statement( $where ) {
global $wp_query;
global $expp;
global $wpdb;
$local_db = $wpdb-prefix."posts";
$front_page_id = get_option('page_on_front');
if ( ('page' != get_option('show_on_front') || $front_page_id != $wp_query-query_vars['page_id']) (!($wp_query-is_search)) )
return $where;
//some $where modifications
remove_all_actions ( '__after_loop');
return $where;
}
Is there any other function or a way to make this hook/filter only work with the search query? (the one that fetches the results from the user input)
Topic request-filter posts-where filters Wordpress
Category Web