Home Forums Gutenberg Is it possible to trigger a block refresh?


Is it possible to trigger a block refresh?

  • Hi all,

    What I’m trying to do is getting post custom fields to auto-populate an ACF Gutenberg block added to the editor. I’ve managed to do some of that with this snippet and then fetching meta with the $post_id.

    // Get post ID in preview mode
    if ( $is_preview ) {
    	$post_id = $_POST['post_id'];

    This means the block is not immediately updated when the post meta is changed obviously, but nor is the preview refreshed when the post is saved (because it doesn’t refresh the page).

    So I wonder if it’s possible at all to trigger a block refresh when a post custom field is updated, as it happens with ACF Gutenberg blocks.

    I understand saving post meta directly from blocks as suggested in acf/issues/83 would cleverly solve this, but any pointers are welcome.

    Thanks in advance!

  • I’m running into this issue as well and would love to know if it’s possible to trigger a re-render when specific fields like the post-title or featured-image have been changed, per example.

  • Jumping on the vagon too. Some sort of refresh would be realy nice.
    Blocks displaying completely irrelevant content after post save is rather jarring 😀

  • I’m looking for this ability, too…

  • +1, this would be extremely useful. When the field is output within an <InnerBlocks /> template, I’m finding that I have to not only publish the post, but then refresh the editor and save it a second time for the data to resolve fully and render on the frontend.

Viewing 7 posts - 1 through 7 (of 7 total)

The topic ‘Is it possible to trigger a block refresh?’ is closed to new replies.