0

How can i display in loop (paged) the posts without the default featured image ? Here is my query of my custom taxonomy template page :

         <?php 
            $term_region = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) );
            $secteur_id = $_GET["secteur_id"];
if($secteur_id == ""){
            $args = array(
                'post_type' => 'visite',
                'paged' => $paged,
                'tax_query' => array(
                    array(
                        'taxonomy' => 'regions',
                        'field' => 'slug',
                        'terms' => $term_region->slug,
                        )
                    )
                );

         $wp_query = new WP_Query($args);
         ?>

I know this kind of query to display only posts with not the default "thumbnail" :

<?php 
    $args = array(
        'post_type' => 'visite',
        'posts_per_page' => 5,
        'meta_query' => array(
            array(
                'key' => '_thumbnail_id',
                'value' => '556',
                'compare' => 'NOT LIKE',
            )
        )
        );          

 $wp_query = new WP_Query($args);
?>

Any idea ? Thank you

1
  • Maybe I'm understanding you wrong, but wouldn't be not using - for example, because maybe you get your thumnail another way - get_the_post_thumbnail() in your template the simple way to not show thumbnails. Jul 3, 2013 at 9:29

1 Answer 1

0

note: Your code is not a loop, it's a query to get a list of posts.

In your template there should be a loop (using that list of posts) with a function to call the featured image. This is where you should change the template, and remove the call to the featured image.

If you are only trying to select posts with no featured image, it is a completely different case. I'm not sure it can be done with a query. A simpler solutions could be to write a if-statement in your loop, to check if post has a featured image, if not, showing the post. This isn't a pretty solution, because it could be possible that you query 20 posts, but since all have a featured image, none will be displayed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.