I've built the following snippet from other post examples that say doing query modification any other way is punishable by great scorn, but it's not working. I'm getting results that include non-published posts and pages which clearly shouldn't happen:
function post_conditions($where)
{
$where .= "AND post_content NOT LIKE '%::exclude tag::%'";
return $where;
}
add_filter('posts_where','post_conditions');
function mysearch($query)
{
$query->set('post_type','post');
$query->set('post_status','publish');
$query->set('posts_per_page',20);
$query->set('paged',get_query_var('paged'));
}
add_action('pre_get_posts','mysearch');
while( have_posts() ){
the_post();
echo get_the_excerpt();
the_tags();
}
if (get_query_var('paged'))
my_paged_function();
wp_reset_query();
The get variables look like so: ?s=mysearchterm&submit=+GO%21+
On my blog template, I'm using the verbotten query_posts() function to achieve the same effect and it works perfectly.
I don't know what's going wrong. Any ideas?