The native search page runs a query like so:
SELECT SQL_CALC_FOUND_ROWS wp_posts.*
FROM wp_posts
WHERE 1=1 AND (((wp_posts.post_title LIKE '%keyword%')
OR (wp_posts.post_content LIKE '%keyword%'))
AND (wp_posts.post_password = '')
AND wp_posts.post_type IN ('post', 'page', 'attachment')
AND (wp_posts.post_status = 'publish')
ORDER BY wp_posts.post_date DESC LIMIT 0, 10
I am passing specific post IDs to the query by hooking into pre_get_posts so I don't need the other WHERE
conditions related to the keyword. e.g.
add_filter('pre_get_posts','my_search_filter');
function my_search_filter($query) {
if ($query->is_search) {
// post IDs within distance X
$matches = array(1,3,5);
$query->query_vars['post__in'] = $matches;
}
}
How can I remove the conditions related to post_title and post_content from the query object by modifying the existing query rather than writing a new one.