Home Forums Gutenberg Update block preview on post title/fields change


Update block preview on post title/fields change

    • foyle

    • November 10, 2019 at 12:43 am

    Greeting! I have a question regardin the block preview update. Imagine an ACF Block displaying 3 pieces of information:

    – The post title via get_the_title().
    – A text field in the document/post scope via get_field( ‘field’, $post_id ).
    – A text field inside of the block via get_field( ‘field’ ).

    While editing the block field, the preview is constantly updated. That’s great but unfortunately the same doesn’t apply for the other two: in order for the preview to be updated I need to save the post and then reload the page. Is there any other way?

  • Wondering this as well. So far I can only get the title of the block (same as title of the post) to update when I refresh the page.

  • I thought it through a bit and came up with the code below. It works for my block, only on the back-end because we’re just using PHP on the front-end.

    if (is_admin()) { ?>
      document.querySelector('.editor-post-title__input').addEventListener('input', (e) => {
       var title =;
       document.querySelector('.SELECTOR-OF-ELEMENT-YOU-WANT-TO-CHANGE').innerHTML = title;
    <?php }
  • Block only containing Inner Blocks selected appearance in editor. 0; Gutenberg · 16 hours, … Update block preview on post title/fields change.

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

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.