3

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....

1

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' );
  • 1
    This answer was correct at the time it was authored, but there was a bug in WordPress which has been fixed quite some time ago see trac ticket #16215. This fix rendered this answer wrong. @Riccardo posted a corrected answer by now, which should be the accepted answer as of now. – JHoffmann Dec 8 '17 at 20:36
6

Seems this will do the job:

remove_action('pre_post_update', 'wp_save_post_revision');// stop revisions

and

add_action('pre_post_update', 'wp_save_post_revision');//  enable revisions again
0

Easiest way is to set WP_POST_REVISIONS contant to false, additional information about post revision management

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.