Skip to content

Instantly share code, notes, and snippets.

@renanlara
Created October 28, 2013 14:37
Show Gist options
  • Save renanlara/7197798 to your computer and use it in GitHub Desktop.
Save renanlara/7197798 to your computer and use it in GitHub Desktop.
Show images attached of post
<?php if( have_posts() ) : while( have_posts() ) : the_post();
$posts = get_posts(array(
"showposts" => -1,
"what_to_show" => "posts",
"post_status" => "inherit",
"post_type" => "attachment",
"orderby" => "menu_order",
"order" => "ASC",
"posts_per_page" => 1,
"post_mime_type" => "image/jpeg,image/gif,image/jpg,image/png",
"post_parent" => get_the_ID()
)); ?>
<?php foreach( $posts as $attachment ) {
$image_attributes = wp_get_attachment_image_src( $attachment->ID, 'photo-thumb' );
$image_attributes_large = wp_get_attachment_image_src( $attachment->ID, 'large' ); ?>
<a href="<?php the_permalink(); ?>"><img src="<?php echo $image_attributes_large[0]?>" height=" " width=" " /></a>
<?php }?>
<?php endwhile; endif;?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment