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?
- Order Search Results Page by meta_value If no Value Return Remaining Results
- Tracing the life of a query
- How to know which one is the main query?
- Finding all results from database within 500 miles of the given latitude and longitude [closed]
- Get random terms
- Dynamically Override Fancy Title – Part II
- Get the post permalink within the loop but without additional DB query
- List the 5 most recent child pages
- WP Query search for attachments and their exact title
- Query total number of posts
- new WP_Query(), have_posts() return false in user_register hook
- Query posts intersecting tags and categories
- Query all posts if multiple meta key don’t exist
- Taxonomy order exception for specific term
- How do I amend wp_query before it is run/executed?
- How to make posts unqueryable/unpublish posts where ACF relationship field is an unpublished post? [closed]
- Getting the post terms ‘wp_get_post_terms’ per post when within the functions.php file
- Posts Query | Query to only show sub categories
- Is it possible to retrieve posts depending on meta_key LIKE condition? [duplicate]
- WP_User_Query orderby meta_val_num
- WP_Query custom order and pagination
- specific post is not excluded from the loop
- Unable to paginate a custom page query
- Determine if ID is page or post and query the ID
- How can I modify this code to make the search box include tags and meta
- Change search query in wordpress custom post type
- Exclude post from wp_query based on custom field boolean
- Order posts by tags count?
- Is there a way to control both Order By and Order query parameters from one input field
- How to define a custom hierarchy for terms?
- Some doubts about how the main query and the custom query works in this custom theme?
- orderby in WP_QUERY – Use the order from the Dashboard
- Random posts in WP_Query when searching by tag
- Combine privileged users array with my current query
- meta_query dates from an array
- Having trouble using this post category query on multiple pages?