• Skip to primary navigation
  • Skip to main content
Sal Ferrarello
  • About Sal Ferrarello
  • Speaking
  • Connect
    Mastodon GitHub Twitter (inactive)
You are here: Home / Dev Tips / WordPress Gutenberg Trigger Autosave

WordPress Gutenberg Trigger Autosave

Last updated on April 25, 2022 by Sal Ferrarello

Recently, I was documenting the steps to reproduce a certain bug and the bug required the presence of an autosave (along with the “There is an autosave of this post that is more recent than the version below.” message). Rather than wait for an autosave to occur naturally, I wanted to speed things up and manually trigger one.

Manually Trigger the “There is an autosave…” Notification

In order to display the “There is an autosave…” notification, we need to do the following:

  1. Update the content in the body of the editor
  2. Trigger the Autosave
  3. Reload the page

1. Update the Content in the Body of the Editor

Update the content in the body of the editor (I’ll often add an extra period to the end of a sentence).

Do NOT Save or Update the post. The message is only displayed when the autosave has changes not included in the saved version.

2. Trigger the Autosave

Run the following from the browser console.

await wp.data.dispatch('core/editor').autosave();

Running a command in the browser console to trigger an autosave in the Gutenberg editor.

3. Reload the Page

When you reload the page, you should see the notification.

"There is an autosave of this post that is more recent than the version below." notification.

Sal Ferrarello
Sal Ferrarello (@salcode)
Sal is a PHP developer with a focus on the WordPress platform. He is a conference speaker with a background including Piano Player, Radio DJ, Magician/Juggler, Beach Photographer, and High School Math Teacher. Sal can be found professionally at WebDevStudios, where he works as a senior backend engineer.

Share this post:

Share on TwitterShare on FacebookShare on LinkedInShare on EmailShare on Reddit

Filed Under: Dev Tips, Solution Tagged With: Gutenberg, JavaScript, WordPress

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Copyright © 2023 · Bootstrap4 Genesis on Genesis Framework · WordPress · Log in