I found this code online. Its a code that only shows posts with images inside. Now, the problem is that if you set Wordpress to show 50 posts, this code shows the posts with the images, but also counts the ones without.
With other words.. if you got 50 posts on your frontpage where 6 are with images this code shows only 6 posts.
Does anyone know how I can make it show 50 posts (the same as set in WordPress) with images?
<?php
while ( have_posts() ) : the_post();
$content = $post->post_content;
$searchimages = '~<img [^>]* />~';
preg_match_all( $searchimages, $content, $pics );
$iNumberOfPics = count($pics[0]);
if ( $iNumberOfPics > 0 ) {
//your loop content goes here
}
endwhile;
?>