Wordpress get attachements for post or page


/ Published in: PHP
Save to your folder(s)

Gets a post or page's attached images and outputs them.


Copy this code and paste it in your HTML
  1. $args = array(
  2. 'post_type' => 'attachment',
  3. 'post_mime_type' => 'image',
  4. 'post_parent' => $post->ID
  5. );
  6. $images = get_posts( $args );
  7. foreach($images as $image):
  8. echo wp_get_attachment_image($image->ID, 'medium');
  9. endforeach;

URL: http://stackoverflow.com/questions/1815158/show-attached-image-to-post-on-wordpress

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.