You could try something like this below.
Basically, if we are performing a search and it is the main_query (the query that generates the page results) ignore the default search and perform an exact match via the query_where
function custom_product_search_exact_match( $query ) {
global $wpdb;
if ( is_search() && is_main_query() && !empty( $query->query_vars['s'] ) ) {
$search_term = $query->query_vars['s'];
$query->query_vars['s'] = '';
$query->query_where .= " AND ($wpdb->posts.post_title="$search_term")";
}
return $query;
}
add_filter( 'pre_get_posts', 'custom_product_search_exact_match' );
Related Posts:
- How to show terms from another taxonomy
- When should you use WP_Query vs query_posts() vs get_posts()?
- Wp get all the sub pages of the parent using wp query
- How to query for most viewed posts and show top 5
- WP Query where title begins with a specific letter
- WP_Query vs get_posts
- Query Custom Meta Value with Increment
- Get posts by meta data OR title
- Perform query with meta_value date
- WP_Query ordered by custom field that is a date string?
- Multiple search queries on one page
- Pass the same object to multiple widgets in a template with one query
- Retrieve or Query Pages by ID
- How do you query wordpress posts using a math formula between multiple meta field values?
- How to implement time filter to show random post 1 month for one category and 3 months for other categories
- Page navigation doesn’t show when query category
- Empty tax_query array returns an empty array
- How do I search inside specific taxonomies in WordPress
- Pass array of taxonomy terms to wp_query
- Custom category search box for WordPress
- How to find exact match for search term in WP_Query? What is the additional string added in LIKE query in WP_Query?
- Creating a custom search for a specific post type
- How to query a custom post type with a taxonomy filter but display post type archive page?
- Querying on multiple taxonomies pulled from $_GET checkbox array not working?
- Change query_posts to WP_Query in page but does not work
- Custom Query num_rows returns wrong amount
- Editing the default wordpress search
- Slow page loads due to WordPress Core Query
- Query Page Content From Theme Options?
- Modify Search Query if original Query gave no results
- How can I override one post and make it display content for another post?
- Include current post into loop
- Filter Custom Taxonomy Posts
- Filter post query to only show direct children of category
- Get a list of posts by specific category
- How to add custom meta to ‘pre_get_terms’?
- Should I reset $wp_query?
- Why doesn’t my WP Meta Query return any results?
- Filter products on category AND tag
- pre_user_query vs pre_get_posts
- Get posts that match defined arrays of tags
- I need query_posts() to order results first by a meta value and then by post ID
- Add to search posts query array with post IDS which will appear first
- Search has query that will return no results
- WP Query – Search in title or author_name
- How to show post title in content editor in backend?
- My entry results are not consistently alphabetized
- Merge two queries and remove duplicate
- WP Query Relations / Compare
- How can I modify standard search query to include also ACF custom fields values?
- Ordering Posts by parent category, name ascending
- Search Functionality broken by the wp 4.2 update
- Optimising specific Query with ACF meta objects
- How to get several fields from wp_query?
- How to organize a WP_Query’s list of posts by category and display category title?
- Need help setting up a search form for wordpress [duplicate]
- When should you use WP_Query vs query_posts() vs get_posts()?
- How to query post ids liked by the Author
- WordPress Query showing multiple titles
- Query Posts by date range with fixed beginning and end
- custom query to get posts
- Search query alteration not working for meta values
- Search results stuck on page 1
- Advanced Search – Is this possible?
- Rewrite URL custom search query
- WP_Comment_Query pagination, delving into the unknown
- Sort posts by category name and title
- Best practice for multiple queries on page
- How to limit search to first letter of title?
- Pagination wont work with search results template [duplicate]
- how to retrieve specific product attribute value in an sql query?
- How to find out what “Blog pages show at most” is set to [duplicate]
- Searching through different categories on different pages code is not working
- How to correctly pass values to wpdb->prepare()?
- Complex date range with WP_Query and BETWEEN
- showing all search result in one template
- List custom taxonomy terms sharing posts with a term from a second custom taxonomy
- Multiple loops without repeating content
- Multiple Search Terms WP_Query
- WP Query Args – Title or Taxonomy Value
- Display custom tags on pages that have a specific page parent
- Categorising search results based on Custom Fields
- Query for first 3 posts to change the look and feel
- Query where ANDing slug values not working
- change posts_orderby of the callback wp_query?
- How to SQL query posts IDs by categories AND authors?
- Search.php – return number of results but cannot loop through
- Can’t get term id for category archive
- Query multiple post types, but different order for each
- Custom query for custom post type not getting correct post ID
- How to get_comments() ordered by date and parent?
- Fetch only categorized posts
- Query posts by custom fields
- Showing posts from 4 categories along with all latest posts
- Searching in specific custom post type
- WordPress pagination returns the same posts
- WordPress WP_Query Search (‘s’) With Multiple Search Terms
- Use value from meta key array for use in WP_Query
- posts_per_page showing 16 elements instead of 3
- query loop “inherit query from template” prevents setting sort order