How to trigger block code AFTER all block editor content is loaded?
-
I’m working on a block that uses the WP featured image for a page/post. I’m using the following to fetch the featured image id and image.
const id = wp.data.select('core/editor').getEditedPostAttribute('featured_media'); const image = wp.data.select('core').getMedia(id);
However, say you save the post and later come back to open and edit it. When you first open that post, my block needs to grab the image once the page is loaded.
I’m finding the methods above return null/undefined when the page first loads. It seems my blocks loads before the above data is available from the store.
Is there any event or hook that I can use to fire code after the block editor and all associated content / data is fully loaded?
- The topic ‘How to trigger block code AFTER all block editor content is loaded?’ is closed to new replies.