This question already has an answer here:
I want to get number of images from blog page of wordpress..i have a code to get image nw but its giving me only images from individual post ..
Following is my code to get no of images in post ..
$count_posts1 = wp_count_posts();
$published_posts = $count_posts1->publish;
echo "<br />number of post -----".$published_posts;
$postimg = array();
for ($j=0; $j<$published_posts; $j++)
{
$szPostContent = $post->post_content;
$szSearchPattern = '#(<img.*?>)#';
$a='';
$aPics='';
preg_match_all( $szSearchPattern, $szPostContent, $aPics );
$iNumberOfPics = count($aPics[$j]);
echo "<br />Number of pics on each post...............".$iNumberOfPics;
}
I want to get count of total images in active/published posts. i could get no of published posts in blog and also no of images in single posts ..But how to integrate it in order to get all total count???
</div>