Search product by title and short description
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
add_filter( "wpo_custom_product_search", function($do_custom_search,$query_args,$term) { //don't do custom search , just set filter add_filter("posts_where", function($where,$query) { global $wpdb; $custom_conditions = array(); foreach($query->query_vars['search_terms'] as $term) { $like = "%" . $wpdb->esc_like( $term ) . "%"; $custom_conditions[] = "CONCAT({$wpdb->posts}.post_title,{$wpdb->posts}.post_excerpt) LIKE '$like'"; } $custom_where = join( " AND ", $custom_conditions); return $where. " OR " . $custom_where; }, 10, 2); return false; }, 10, 3); |