Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
WordPress filter to set number of revisions based on post type
/**
* minimize unnecessary revision storage (based on post type)
*/
add_filter( 'wp_revisions_to_keep', function ( $nr_revisions, $post ) {
switch ( $post->post_type ) {
case 'page':
case 'movie':
case 'article':
case 'story':
$nr_revisions = 3;
break;
case 'post':
default:
$nr_revisions = 0;
break;
}
return $nr_revisions;
}, 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.