Should I hint table index for search query on wp_post
Should I hint table index for search query on wp_post
Should I hint table index for search query on wp_post
Copy the following snippet and paste it into the code of your theme, preferably in the functions.php file: /* Exclude a Category from Search Results */ add_filter( ‘pre_get_posts’ , ‘search_exc_cats’ ); function search_exc_cats( $query ) { if( $query->is_admin ) return $query; if( $query->is_search ) { $query->set( ‘category__not_in’ , array( 30 ) ); // Cat ID … Read more
// Above the loop on your search result template: if ( is_search() ) // Are we on a search result page? { global $wp_query, $query_string; // now modify/filter the query (result) query_posts( $query_string . ‘cat=1&tag=apples+apples’ ); }
There’s a few ways you could do this. I once wrote some extended code to integrate Apache Solr with WordPress search and BuddyPress and that added a lot of power. With something like Apache Solr you can customize weight and do some interesting things. Solr is a full fledged search engine and you will need … Read more
You may want to put the following code global $wp_query; var_dump($wp_query->request); before the <?php if ( have_posts() ) : ?> line to check the exact SQL statement. Maybe running it did return only one result.
This snippet should solve your problem. Just put it into your functions.php file. function my_insert_rewrite_rules( $rules ) { $newrules = array(); $newrules[‘search/([^/]+)/post_type/([^/]+)/?$’] = ‘index.php?s=$matches[1]&post_type=$matches[2]’; return $newrules + $rules; } add_filter( ‘rewrite_rules_array’,’my_insert_rewrite_rules’ ); function my_flush_rewrite_rules() { flush_rewrite_rules(); } add_action( ‘after_switch_theme’, ‘my_flush_rewrite_rules’ ); You will have to flush rewrite rules after adding this code, before it will … Read more
The answer is taken from WordPress.org Support Forum thread: » 3.6 upgrade – searchform.php not working As salcode said: Adding this code to your functions.php should do the trick: function search_form_no_filters() { // look for local searchform template $search_form_template = locate_template( ‘searchform.php’ ); if ( ” !== $search_form_template ) { // searchform.php exists, remove all … Read more
You’re confusing “post type support” – which means enabling “feature” (and therefore MetaBoxes) for a post – with templating. Go into your theme, search for the search.php template in the folder. Add a Child Theme Add a file named search.php to your Child theme and copy/paste the content of your parent themes template file in … Read more
I wonder if this will work for you: function search_filter( $query ) { if( $query->is_search AND $query->is_main_query() ) { // $query->set( ‘post_parent__not_in’, array( 0 ) ); // We comment this out here $query->set( ‘post_type’, array( ‘post’, ‘page’ ) ); } return $query; } add_action( ‘pre_get_posts’, ‘search_filter’ ); and function wpse_120638( $where, $query ) { global … Read more
You need to use the user_search_columns filter to add the columns you want to search on. The user_search_columns filter is used to determine which user fields in the database are used when performing a search on user information. https://codex.wordpress.org/Plugin_API/Filter_Reference/user_search_columns