Using Add Media
I am inserting images in the Post.I want to reterive these only these images on the single post page.I am using get_attached_media
function to reterive these images.But it returns an empty array.
<?php $media_image = get_attached_media( 'image', $post->ID ); //print_r($media_image);?>
<div class ="single-post-flex-slider">
<ul class="slides">
<?php foreach($attachments as $image){
$image_attr = wp_get_attachment_image_src( $image->ID,array(500,500) );
?>
<li> <img src="<?php echo $image_attr[0] ?>" width="<?php echo $image_attr[1] ?>" height="<?php echo $image_attr[2] ?>" /></li>
<?php } ?>
</ul>
</div>
is_single
print_r($media_image)
returns an empty array.but thepost
returns the values in an array