Dynamically update post title in admin page

The block editor is restoring back the title that was last saved (or typed manually into the textarea), so with the block editor, you can change the title dynamically using this code:

wp.data.dispatch( 'core/editor' ).editPost( { title: 'Title here' } )

PS: You should make sure your JS file has the wp-editor, wp-edit-post or wp-data as part of the dependencies.

UPDATE

Here are the resources which helped me identify the above solution/code:

Leave a Comment