Show Attached Image to Post on Wordpress
-
06-07-2019 - |
Question
How i can show attached images of my posts on Wordpress?
Solution
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;
OTHER TIPS
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow