Support » Themes and Templates » "get_children" not working on archive

  • I’m using this code within the loop to display the number of photos attached in each post and it works perfectly on the single.php template but on the archive template it only displays 0:

    <?php $attachments = get_children(array('post_parent'=>$post->ID)); $nbImg = count($attachments); echo $nbImg; ?>

    Any suggestions? I’m guessing it’s to do with the $post->ID but I’m not sure how to work around that…

Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘"get_children" not working on archive’ is closed to new replies.