sinanisler logo

Change Increase WordPress Revision History Setting

Default revision history setting is lame not even useful..

Add this code to the fucntions.php this makes the revision history 600 I use it all the time.

it makes the db grow faster but saves time when you need to reroll something back…

 

// WP Revision History Count , Set to 600
// Add more post types if needed
// Default definer = define( 'WP_POST_REVISIONS', 600 );


add_filter( 'wp_revisions_to_keep', function( $num, $post )
{
    // Post Types and Revision Numbers - Edit to your needs
    $config = [
        'post' => 600,
        'page' => 600
    ];

    // Get the current post type
    $post_type = get_post_type( $post );

    // Override the WP_POST_REVISIONS value
    if( isset( $config[$post_type] ) && is_int( $config[$post_type] ) )
        $num = $config[$post_type];

    return $num;
}, 10, 2 );

 

 

Leave the first comment