I'm attempting to grab only the images from a page in Wordpress.
I read there was a function called get_post_gallery()
but it doesn't seem to obtain my images. This is what I did:
if ( get_post_gallery() ) :
$images = get_post_gallery(get_the_ID(), false);
foreach($images as $image)
{
echo $image['src'];
}
endif;
This line of code is put inside the loop
from what I understand like so:
if ( have_posts() ) {
\\Bit of code in here
}
However, the array that it returns appears to be empty (even though there are images in the post page editor). Do you guys suggest this way or another way to retrieve only images from a post/page?