I have a query running which prevents posts without various criteria from appearing, one of these is the necessity to have a featured image. Sticky posts however seem to end up in the query regardless. How can I achieve this?
$args = array(
'posts_per_page' => $articles_no,
'meta_key' => '_thumbnail_id',
'post__not_in' => $a_empty_titles,
// remove post formats as per theme options ( using $hide from above )
'tax_query' => array(
array(
'taxonomy' => 'post_format',
'field' => 'slug',
'operator' => 'NOT IN',
'terms' => $hide
)
)
);
$fp_query = new WP_Query( $args ); ?>
<ul class="thumbnails">
<?php
$thumbnail_span = "span4";
if( $fp_query->have_posts() ) : while( $fp_query->have_posts() ) : $fp_query->the_post(); ?>
... Typical Formatting Follows ...
... Posts without featured images should have been excluded but "sticky" posts seem to persist
Per the Codex article on WP Query:
Adding
'ignore_sticky_posts' => 1
to your$args
array will stop sticky posts from showing up when you don’t want them. Then'meta_key' => '_thumbnail_id',
can succeed at filtering out posts without featured images.