Keep sticky posts out of query unless they have featured image

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

Related posts

Leave a Reply

1 comment

  1. Per the Codex article on WP Query:

    ignore_sticky_posts (boolean) – ignore sticky posts or not. Default value is 0 – don’t ignore sticky posts. Note: ignore/exclude sticky posts being included at the beginning of posts returned, but the sticky post will still be returned in the natural order of that list of posts returned.

    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.