Retrieve an array of image URLs that belong to a gallery

I am creating an image slider for the gallery post type. The code below works fine with the classic gallery, however when I use the new Gutenberg gallery block the get_post_gallery_images() function doesn’t retrieve the array of image URLs.

$images = get_post_gallery_images();
echo ‘<div class=”image-row”>’;
foreach ( $images as $image ) {
echo ‘<div class=”image-container”>’;
echo ‘<img src=”‘ . $image . ‘” />’;
echo ‘</div>’;
}
echo ‘</div>’;

Read more here:: Retrieve an array of image URLs that belong to a gallery

Leave a Reply

Your email address will not be published. Required fields are marked *