You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note: It's likely that this is not related to Gutenberg, but an issue that should be reported and handled in WordPress Trac. Please let me know if I should do so.
Step-by-step reproduction instructions
Add a new post or edit an existing one (you can even use the "Sample Page")
Add a gallery block somewhere on the post
Use get_post_galleries() to retrieve the gallery blocks
See that the function returns all blocks
Screenshots, screen recording, code snippet
Code snippets
Use this code snippet in functions.php:
add_filter(
'the_content', // or 'render_block', etc.staticfunction (string$content): string {
$galleries = get_post_galleries(get_the_ID());
return$content; // set breakpoint here to inspect contents of $galleries
}
);
Example editor content (gallery images redacted; use your own images)
<!-- wp:paragraph --><p>This is an example page. It's different from a blog post because it will stay in one place and will show up in your site navigation (in most themes). Most people start with an About page that introduces them to potential site visitors. It might say something like this:</p><!-- /wp:paragraph --><!-- wp:gallery {"linkTo":"none"} --><figureclass="wp-block-gallery has-nested-images columns-default is-cropped"><!-- wp:image {"id":7,"sizeSlug":"large","linkDestination":"none"} --><figureclass="wp-block-image size-large"><imgsrc="[…]" alt="" class="wp-image-7"/><figcaption>OLYMPUS DIGITAL CAMERA</figcaption></figure><!-- /wp:image --><!-- wp:image {"id":8,"sizeSlug":"large","linkDestination":"none"} --><figureclass="wp-block-image size-large"><imgsrc="[…]" alt="" class="wp-image-8"/><figcaption>OLYMPUS DIGITAL CAMERA</figcaption></figure><!-- /wp:image --><!-- wp:image {"id":9,"sizeSlug":"large","linkDestination":"none"} --><figureclass="wp-block-image size-large"><imgsrc="[…]" alt="" class="wp-image-9"/></figure><!-- /wp:image --><!-- wp:image {"id":6,"sizeSlug":"large","linkDestination":"none"} --><figureclass="wp-block-image size-large"><imgsrc="[…]" alt="" class="wp-image-6"/></figure><!-- /wp:image --></figure><!-- /wp:gallery --><!-- wp:quote --><blockquoteclass="wp-block-quote"><p>Hi there! I'm a bike messenger by day, aspiring actor by night, and this is my website. I live in Los Angeles, have a great dog named Jack, and I like piña coladas. (And gettin' caught in the rain.)</p></blockquote><!-- /wp:quote --><!-- wp:paragraph --><p>...or something like this:</p><!-- /wp:paragraph --><!-- wp:quote --><blockquoteclass="wp-block-quote"><p>The XYZ Doohickey Company was founded in 1971, and has been providing quality doohickeys to the public ever since. Located in Gotham City, XYZ employs over 2,000 people and does all kinds of awesome things for the Gotham community.</p></blockquote><!-- /wp:quote --><!-- wp:paragraph --><p>As a new WordPress user, you should go to <ahref="http://stock-wordpress.local/wp-admin/">your dashboard</a> to delete this page and create new pages for your content. Have fun!</p><!-- /wp:paragraph -->
Screenshots get_post_galleries(get_the_ID)):
get_post_galleries(get_the_ID), false) (return data instead of HTML):
Environment info
WordPress 5.9
no Gutenberg plugin
Theme: Twenty Twenty-Two
Chrome 98
macOS 11.6.4
Please confirm that you have searched existing issues in the repo.
Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Yes
The text was updated successfully, but these errors were encountered:
Thanks a lot @glendaviesnz! Before creating this issue, I was searching for existing issues in both Trac and GitHub. Either I used the wrong search terms or too much time passed after I realized the bug and before I found the time to report it 😉 🤷🏽
Description
When using
get_post_galleries()
to get the editor galleries of a post (editor support for that function landed in WordPress 5.9, see https://core.trac.wordpress.org/ticket/43826#comment:58), the function will not only return the gallery blocks but all blocks of that post.Note: It's likely that this is not related to Gutenberg, but an issue that should be reported and handled in WordPress Trac. Please let me know if I should do so.
Step-by-step reproduction instructions
get_post_galleries()
to retrieve the gallery blocksScreenshots, screen recording, code snippet
Code snippets
Use this code snippet in
functions.php
:Example editor content (gallery images redacted; use your own images)
Screenshots
get_post_galleries(get_the_ID))
:get_post_galleries(get_the_ID), false)
(return data instead of HTML):Environment info
Please confirm that you have searched existing issues in the repo.
Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Yes
The text was updated successfully, but these errors were encountered: