Posted By

JoshChris on 07/11/13


Tagged


Versions (?)

Get all attached images for a wordpress post/page


 / Published in: PHP
 

Short php snippit to get all images that are attached to a post or page in wordpress. Need to mod to only get gallery images.

  1. <?php
  2. $attachments = get_children( array('post_parent' => get_the_ID(), 'post_type' => 'attachment', 'post_mime_type' =>'image') );
  3. foreach ( $attachments as $attachment_id => $attachment ) {
  4. echo wp_get_attachment_image( $attachment_id, 'medium' );
  5. }
  6. ?>

Report this snippet  

You need to login to post a comment.