Get image attachment to a post outside the loop?
try using get_attached_media function and your current $postID $images = get_attached_media( ‘image’, $postID ); this will return a WP_Post object. If you want to get the url, it’s located in the guid key of the object. Use a foreach loop to retrieve them all. foreach( $images as $image ){ $src[] = $image->guid; } To use … Read more