检查:https://codex.wordpress.org/Function_Reference/wp_update_post
确保不要创建无限循环。
<?php
function my_function( $post_id ){
if ( ! wp_is_post_revision( $post_id ) ){
// unhook this function so it doesn\'t loop infinitely
remove_action(\'save_post\', \'my_function\');
// update the post, which calls save_post again
wp_update_post( $my_args );
// re-hook this function
add_action(\'save_post\', \'my_function\');
}
}
add_action(\'save_post\', \'my_function\');
?>
要停止修订,请尝试添加:
https://wordpress.stackexchange.com/a/3398remove_action(\'pre_post_update\', \'wp_save_post_revision\');// stop revisions
以及
add_action(\'pre_post_update\', \'wp_save_post_revision\');// enable revisions again
祝你好运;-)