I have been trying to retrieve the image block's caption text to use in a PHP file.

I understand Gutenberg (Block Editor) is relatively new so I haven't found any documentation on this topic.

I have tried using common Wordpress attachment functions but they all retrieve info from the attachment page (title, description, etc.) and not from the page I'm editing and adding the image as a block.

In other words, when you add an image block to a new page you can add a tiny caption below it. That's the text I'm trying to retrieve in the PHP file so it makes it easier for my client to upload images to pages intuitively.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.