fatihturan
fatihturan

Reputation: 135

Show Attached Image to Post on Wordpress

How i can show attached images of my posts on Wordpress?

Upvotes: 5

Views: 9018

Answers (2)

Adam Dempsey
Adam Dempsey

Reputation: 2962

Try this in your single.php template:

$args = array(
'post_type' => 'attachment',
'post_mime_type' => 'image',
'post_parent' => $post->ID
);
$images = get_posts( $args );
foreach($images as $image):
echo wp_get_attachment_image($image->ID, 'medium');
endforeach;

Upvotes: 14

Soufiane Hassou
Soufiane Hassou

Reputation: 17750

wp_get_attachment_image

Upvotes: 1

Related Questions