# "Minor Edit" Option That Keeps the Last Updated Date

> Adds a "Minor edit" checkbox to the block editor; when ticked, fixing a typo does not change the post's last modified date, so "Updated on" labels and sitemaps only change for real updates.

- Type: PHP
- Runs: Run everywhere
- Category: [Content](https://wpide.com/library/category/content/)
- Tags: block-editor, dates, editorial
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/content-minor-edit-keeps-date/

## Code

```php
add_action( 'init', function () {
    register_post_meta( 'post', '_wpide_minor_edit', array(
        'type'          => 'boolean',
        'single'        => true,
        'default'       => false,
        'show_in_rest'  => true,
        'auth_callback' => function ( $allowed, $key, $post_id ) {
            return current_user_can( 'edit_post', $post_id );
        },
    ) );
} );

// Remember the choice from the REST request before the post is saved.
add_filter( 'rest_pre_insert_post', function ( $prepared, $request ) {
    $meta = $request->get_param( 'meta' );
    $GLOBALS['wpide_minor_edit'] = is_array( $meta ) && ! empty( $meta['_wpide_minor_edit'] ) && ! empty( $prepared->ID );
    return $prepared;
}, 10, 2 );

add_filter( 'wp_insert_post_data', function ( $data, $postarr ) {
    if ( empty( $GLOBALS['wpide_minor_edit'] ) || empty( $postarr['ID'] ) ) {
        return $data;
    }
    $current = get_post( (int) $postarr['ID'] );
    if ( $current && 'publish' === $current->post_status ) {
        $data['post_modified']     = $current->post_modified;
        $data['post_modified_gmt'] = $current->post_modified_gmt;
    }
    return $data;
}, 99, 2 );

// Untick the box after saving.
add_action( 'rest_after_insert_post', function ( $post ) {
    if ( ! empty( $GLOBALS['wpide_minor_edit'] ) ) {
        update_post_meta( $post->ID, '_wpide_minor_edit', false );
        $GLOBALS['wpide_minor_edit'] = false;
    }
} );

add_action( 'enqueue_block_editor_assets', function () {
    $screen = get_current_screen();
    if ( ! $screen || 'post' !== $screen->base || 'post' !== $screen->post_type ) {
        return;
    }

    wp_register_script( 'wpide-minor-edit', false, array( 'wp-plugins', 'wp-element', 'wp-components', 'wp-data', 'wp-editor' ), '1.0', true );
    wp_enqueue_script( 'wpide-minor-edit' );
    wp_add_inline_script( 'wpide-minor-edit', <<<'JS'
( function ( wp ) {
    var el = wp.element.createElement;
    var Panel = ( wp.editor && wp.editor.PluginPostStatusInfo ) || ( wp.editPost && wp.editPost.PluginPostStatusInfo );
    if ( ! Panel ) { return; }

    function MinorEdit() {
        var data = wp.data.useSelect( function ( select ) {
            var editor = select( 'core/editor' );
            return { published: editor.isCurrentPostPublished(), minor: !! ( editor.getEditedPostAttribute( 'meta' ) || {} )._wpide_minor_edit };
        }, [] );
        var editPost = wp.data.useDispatch( 'core/editor' ).editPost;
        if ( ! data.published ) { return null; }

        return el( Panel, null,
            el( wp.components.CheckboxControl, {
                label: 'Minor edit (keep the "last updated" date)',
                checked: data.minor,
                onChange: function ( value ) { editPost( { meta: { _wpide_minor_edit: value } } ); }
            } )
        );
    }

    wp.plugins.registerPlugin( 'wpide-minor-edit', { render: MinorEdit } );
} )( window.wp );
JS
    );
} );
```

## Notes

The checkbox resets after each save; works with the block editor and the REST API.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find ""Minor Edit" Option That Keeps the Last Updated Date" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
