How can I fetch the details of the $post
object of the very post that I'm working on in WP admin? I've tried global $post
but I believe that $post
is not available during editing.
A little context:
I'm digging into Gutenberg by creating my first block and coming up against an issue whereby I don't know how to query properties (type, ID) of the post in the editor. The function which outputs my content (successfully) on the front end uses ACFs get_field
to fetch a value from an ACF field on that post but fails when I attempt to display a preview of the output in the block editor in the absence of the $post->ID.