admin管理员组文章数量:1134247
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....
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....
4 Answers
Reset to default 2To 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' );
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
You can use the wp_revisions_to_keep
filter and return 0
to effectively disable revisions, specify a maximum number of revisions to keep, or return -1
for the default of unlimited revisions. You can add the post parameter to the filter if you would like to adjust for post type.
function my_disable_revisions( $num ) {
return 0;
}
add_filter( 'wp_revisions_to_keep', 'my_disable_revisions' );
Easiest way is to set WP_POST_REVISIONS
contant to false
, additional information about post revision management
本文标签: phpEnabledisable post revisions programmatically
版权声明:本文标题:php - Enabledisable post revisions programmatically 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736836591a1954917.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论