WordPress Search documentation: how to improve search query using taxonomy terms, custom meta fields?

I had the same question a couple of weeks ago. Here’s what I did to make it work for me. How Do I Use WP_Query to Run This Database Query as Search Result? If you’ll read through my answer that I posted for reference’s sake, you’ll see that I ended up adding a filter add_filter(‘post_request’,’your_function_name’); … Read more

Include custom table into search results

It’s probably SQL Full Text Search what you’re looking for. Maybe this tutorial helps you forward: http://www.blrf.net/howto/49_Wordpress__How_to_implement_MySQL_full_text_search_.html There is also a WP plugin with Full Text Search capability, but it’s not updated for a while: http://urbangiraffe.com/plugins/search-unleashed/

Search posts by post author name

This line is likely the issue – $where = ” AND ( atl_posts.post_author = {$authorID} ) “; You are replacing the contents of $where, not changing it. You have to use . before = – $where.= ” AND ( atl_posts.post_author = {$authorID} ) “;

How to support multiple search terms query within one process?

Fixed: Search and result the all keys; <?php $the_keys = preg_split(‘/\s+/’, str_replace(‘-‘,’ ‘,get_query_var(‘s’)),-1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE); $total_keys = count($the_keys); $the_query = new WP_Query(array(‘post_type’=>’nothing’)); if($total_keys>1){ for($i = 0; $i<=$total_keys; $i++) { $the_query_mask = new WP_Query(array(‘s’ => $the_keys[$i])); $the_query->post_count = count( $the_query->posts ); $the_query->posts = array_merge( $the_query->posts, $the_query_mask->posts ); } } else { $the_query= new WP_Query(array(‘s’ => … Read more

How to find objects by terms

Assuming “users” you are trying to pull is a custom post type. You can use “tax_query” as below. $user_args = array( ‘post_type’ => ‘custom_user_post’, // Custom post type, ‘posts_per_page’ => 10, ‘paged’ => ( ! empty( get_query_var( ‘paged’ ) )? get_query_var(‘paged’): 1 ), ‘tax_query’ => array( ‘relation’ => ‘AND’, array( ‘taxonomy’ => ‘user_sports’, //assuming your … Read more

Easy way to process search results before displaying

You can use pre_get_posts filter to filter out what you need. There’s an example on how to do this in Codex: https://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts#Exclude_Pages_from_Search_Results function search_filter($query) { if ( !is_admin() && $query->is_main_query() ) { if ($query->is_search) { $query->set(‘post_type’, ‘post’); } } } add_action(‘pre_get_posts’,’search_filter’); Also, this article might get you in the direction of editing the search form…

Pagination not working for Custom search form & custom result template

i’ve seen this: next_posts_link You must use wp_reset_postdata when use new WP_QUERY(), and this <div class=”pagination” id=”blog-pagination”> <span class=”previous” ><?php previous_posts_link( ‘&larr;Newer’, $loop->max_num_pages ); ?></span> <span class=”next”><?php next_posts_link( ‘Older &rarr;’, $loop->max_num_pages ); ?></span> </div> go into if($loop->have_posts()):?> condition

Search Terms – Querying on either description__like OR name__like in the same Term Query?

I don’t see any options for WordPress to search terms by both of name & description. So i combined 2 queries like @StephanieQ but maybe more simple way, checkout my ajax response below: public function ajax_project_terms_search() { $results = array(); $search_query = sanitize_text_field($_GET[‘q’]); $withname = intval($_GET[‘withname’]); $search_keys = array(‘name__like’, ‘description__like’); $exclude = array(); foreach ($search_keys … Read more