I have a pre_get_posts()
function that is used by my users to search posts. I've noticed that for whatever reason it seems to be searching text within a post's previous revision that is no longer in the post and return the current post.
ROUGH EXAMPLE:
Previous Revision Title = "I like to analyze"
Current Title = "I like to report"
Now if you search for "analyze" it would return the post with the Current Title
which I would prefer it not to.
I've setup the query in a way I thought would remove this...but it's not:
$search_post_types_array = array('zr_td','st_kb','forum','topic','reply');
$query->set('post_type', $search_post_types_array);
$query->set('post_status', 'publish');
$query->set('post_parent', 0);
Please let me know if you need additional clarification or information.
SQL from $wp_query->request;
SELECT DISTINCT SQL_CALC_FOUND_ROWS wp_posts.* FROM wp_posts LEFT JOIN wp_postmeta AS m ON (wp_posts.ID = m.post_id) WHERE 1=1 AND ( ( wp_posts.post_parent = 0 AND (((((wp_posts.post_title LIKE '%analytics%') OR (wp_posts.post_content LIKE '%analytics%'))) OR ((m.meta_value LIKE '%analytics%')) )) AND wp_posts.post_type IN ('zr_td', 'st_kb', 'forum', 'topic', 'reply') AND ((wp_posts.post_status = 'publish'))) AND post_type != 'revision') AND post_status != 'future' ORDER BY wp_posts.post_title LIKE '{a2ab97c8fd44df4b50f3dc2108b2651d7e3390dcacd7fd0413334d3fd0287ce9}analytics{a2ab97c8fd44df4b50f3dc2108b2651d7e3390dcacd7fd0413334d3fd0287ce9}' DESC, wp_posts.post_date DESC LIMIT 0, 10
meta_value
of each post? Can you confirm that there is noanalyze
value in posts like"I like to report"
?