tags:

views:

20

answers:

2

Anyone can help me with this one?

I've set my posts to have thumbnails. Is there any way to retrieve only posts with thumbnails?

Thanks.

A: 

If you set your posts to have thumbnails the standard way, then you can always check if a post has a thumbnail using the has_post_thumbnail function. I'm not sure there's any way to ask WP_Query for posts with thumbnails, but I'm sure you can do it with a direct SQL query to $wpdb.

kovshenin
A: 

Inside of your wordpress loop just add this wrapper.

if ( has_post_thumbnail() )
{
    // run code for post
}

So your full code would most likely look something like this.

if ( have_posts() )
{
    while ( have_posts() )
    {
        the_post();

        if ( has_post_thumbnail() )
        {
            // output html code for the post here
        }
    }
}
Will Ayers