In WordPress 3 there is Featured Image functionality. How do i fetch all posts that have a featured image with them? Here is my current custom loop:
$loop = new WP_Query( array( 'posts_per_page' => 15 ) );
In WordPress 3 there is Featured Image functionality. How do i fetch all posts that have a featured image with them? Here is my current custom loop:
$loop = new WP_Query( array( 'posts_per_page' => 15 ) );
This should work:
$loop = new WP_Query( array( 'posts_per_page' => -1, 'meta_key' => '_thumbnail_id' ) );
I haven't tested this, though. Also, this will probably fetch all posts and pages. Use 'post_type' => 'post'
to limit it to blog posts.