get_post_gallery with Gutenberg

I have a site where I created a page that takes the gallery images from a post and puts them into a slider.

I used the following code:

// gets the gallery info
$gallery = get_post_gallery( $post->ID, false );
// makes an array of image ids
$ids = explode ( “,”, $gallery[‘ids’] );

Then I inserted the images using wp_get_attachment_image().

Unfortunately, with WP 5.0 and Gutenberg, get_post_gallery no longer works with newly added content. It seems that get_post_gallery used a shortcode that no longer works with Gutenberg.

I am still getting up to speed on Gutenberg and the block system. Until I understand that all better, I was wondering if anyone has any advice on how to get the image ids from a gallery in Gutenberg?

Read more here:: get_post_gallery with Gutenberg

Leave a Reply

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