Force search form to go to clean url without multiple redirects

Assuming you make your form’s action point to the correct URL, here are Two (and a half) Options: With Javascript (jQuery) jQuery(document).ready( function() { jQuery(“#searchform”).submit( function() { self.location.href = jQuery(this).attr(“action”) + jQuery(“#s”).val(); return false; }); }); You could also do it without jQuery (if you don’t use jQuery on your site and don’t want to … Read more

How to filter my search in post if contains a word in title, content or excerpt?

Well, for whoever went under the same question, I found the solution: I’ve changed the filter and looks like this now: add_filter( ‘posts_where’, ‘general_filter’, 10, 2 ); $posts = new WP_Query($args); remove_filter( ‘posts_where’, ‘general_filter’, 10, 2 ); and the function… function general_filter( $where, &$wp_query ) { global $wpdb; if ( $search_term = $wp_query->get( ‘search_prod_title’ ) … Read more

Seach custom post type posts only by meta fields?

This might work, not tested though. First add this to join the postmeta table: add_filter( ‘posts_join’, ‘search_filters_join’, 501, 2 ); function search_filters_join( $join, $query ) { global $wpdb; if ( empty( $query->query_vars[ ‘post_type’ ] ) || $query->query_vars[ ‘post_type’ ] !== ‘product’ ) { return $join; // skip processing } if ( ($this->is_ajax_search() || $this->is_search_page()) && … Read more