I am trying to make a custom search filter on a woocommerce product list page.
I do this using pre_get_posts action when it comes to enabling my filters.
All works well, except when I want to use ‘s’ search paramater of WP_Query;
What I get is very weird. It does the search and shows the relevant results on top, BUT also shows ALL OTHER results below!
I have checked the actual query by echo $GLOBALS[‘wp_query’]->request; at the bottom of my pre_get_posts action and this is what I see:
Whenever I do $query->set( ‘s’, $_GET[‘s’]); the query becomes having this part:
AND ( (wp_posts.ID IN (70845,70847,70849,70851,70853,70855,70857... thousands of records here...., 114175,114177,114179,114181,114183,114185,114197)) OR ((wp_posts.post_title LIKE '%keyword%') OR (wp_posts.post_excerpt LIKE '%keyword%') OR (wp_posts.post_content LIKE '%keyword%')))
So why do I have this strange wp_posts.ID IN part containing all posts? Maybe there is some setting to exclude not matching posts?
Have not found anything!