WordPress: Disable Post Revisions / Turn Off Revisions

www.laut‮c.irut‬om
WordPress: Disable Post Revisions / Turn Off Revisions

To disable post revisions in WordPress, you can add the following line to your "wp-config.php" file:

define( 'WP_POST_REVISIONS', false );

This will disable post revisions for all posts on your site.

Alternatively, you can specify a maximum number of revisions to keep by replacing "false" with the desired number. For example, to keep a maximum of 5 revisions per post, you can use the following line:

define( 'WP_POST_REVISIONS', 5 );

This will keep a maximum of 5 revisions per post and automatically delete any older revisions.

You can also disable post revisions for a specific post or page by using the "wp_revisions_enabled" filter. This filter allows you to disable revisions on a per-post basis by returning false when the filter is called.

Here is an example of how you can use the "wp_revisions_enabled" filter to disable revisions for a specific post:

function disable_revisions_for_post( $revisions_enabled, $post ) {
if ( $post->ID == 123 ) { // Replace "123" with the ID of the post you want to disable revisions for
return false;
}

return $revisions_enabled;
}
add_filter( 'wp_revisions_enabled', 'disable_revisions_for_post', 10, 2 );

This code will disable revisions for the post with an ID of 123. You can modify the code to suit your needs and disable revisions for multiple posts or pages.

Keep in mind that disabling post revisions can result in the loss of revision history for your posts and pages. It is generally a good idea to keep post revisions enabled, especially if you have multiple authors contributing to your site or if you make frequent changes to your content.

Created Time:2017-10-30 14:27:34  Author:lautturi