Enable/disable post revisions programmatically

Is there a way to temporarily disable revisions…. I have noticed that wp_update_post is very slow and creates revisions I don’t need.
The fix could be to disable revisions before issuing wp_update_post and re-enable the feature once done….

3 Answers
3

To keep posts updated, I am working with WordPress 4.4 and to enable/disable post revisions programmatically use:

remove_action( 'post_updated', 'wp_save_post_revision' );
$post_id = wp_update_post( $arg );
add_action( 'post_updated', 'wp_save_post_revision' );

Leave a Comment