How to get Gutenberg Reusable Block content when retrieving post content?

828 Views Asked by At

I’ve created a WordPress plugin that converts post content to speech. It’s not a surprise that on of the basic requirements for such plugin is reliable retrieving post content. I’m using get_post_field('post_content') and everything seems to work fine except one thing: if there’s Reusable Block within posts content – the function doesn’t return it. It gives me all the content except Reusable Block.

Is there some workaround for this?

Thanks!

1

There are 1 best solutions below

0
On BEST ANSWER

I think you'll want to apply the the_content filter to get the reusable blocks' content.

apply_filters('the_content', get_post_field('post_content'));

There may be a more efficient function for pulling the content (get_the_content maybe?), but regardless this should convert the reusable blocks to html.