Turn Off Autosave for Chosen Post Types
Stops the editor from autosaving the post types you list (for example products or custom data types edited by many people), which removes frequent background requests and extra autosave revisions.
Opens WPIDE on
Code
// Post types without autosave.
$wpide_no_autosave_types = array( 'product', 'shop_order' );
add_action( 'admin_enqueue_scripts', function ( $hook ) use ( $wpide_no_autosave_types ) {
if ( ! in_array( $hook, array( 'post.php', 'post-new.php' ), true ) ) {
return;
}
$screen = get_current_screen();
if ( $screen && in_array( $screen->post_type, $wpide_no_autosave_types, true ) ) {
wp_dequeue_script( 'autosave' );
}
} );
add_filter( 'block_editor_settings_all', function ( $settings, $context ) use ( $wpide_no_autosave_types ) {
if ( isset( $context->post->post_type ) && in_array( $context->post->post_type, $wpide_no_autosave_types, true ) ) {
$settings['autosaveInterval'] = 86400;
}
return $settings;
}, 10, 2 );
Notes
Unsaved changes are lost if the browser crashes, so only use it for post types where that is acceptable.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.