I am having a wordpress loop that shows all the posts. I need to have a count of all the images for a particular post.
<?php while ( $the_query->have_posts() ) : $the_query->the_post();
$attachments = get_children( array( 'post_parent' => $post->ID, 'post_mime_type' => 'image' ) );
$count = count( $attachments );
$specific = array();
$i = 1;
foreach ( $attachments as $attachment ) {
$specific[$attachment->ID] = $i;
++$i;
} ?> <a href="#"><?php echo $count; ?></a>
<?php endwhile; ?>
the problem is that, it doesn't works and it does not display images count.