Limit Post Revisions
Keeps only the five most recent revisions of each post, which stops the database from growing with old copies.
Opens WPIDE on
Code
add_filter( 'wp_revisions_to_keep', function ( $num, $post ) {
return 5;
}, 10, 2 );
Notes
Return 0 to disable revisions or -1 to keep all. Existing extra revisions are removed the next time a post is saved.
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.