Post Control/Revisions

WordPress has a nasty habit of keeping a cluttered mess of post revisions. There is a nice little snippet of code you can add to your wp-config file to limit how many are keeping house in your database:

[code xclass=”prettyprint”]define( ‘WP_POST_REVISIONS’, 3 );[/code]

You can also remove post revisions completely with this snippet:

[code xclass=”prettyprint”]define(‘WP_POST_REVISIONS’, false);[/code]

The latter is super-handy if you are developing a site and want a fresh hand-off to a client. It will keep the last auto-save.

You probably didn’t know this, but there is a filter WordPress has where you can also set this on a post-type level:

[code xclass=”prettyprint”]
add_filter( ‘wp_revisions_to_keep’, ‘filter_function_name’, 10, 2 );

function filter_function_name( $num, $post ) {

if( ‘my_custom_post’ == $post->post_type ) {
$num = 5;
}
return $num;
}
[/code]

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments