因此,通过大量的脑力劳动和实验,我设法找到了一个解决方案,让编辑/管理员在前一篇文章保持活跃的同时查看该文章,这相当复杂,但确实有效。
我所做的关键是创建一个新的post状态,我称之为waiting。在管理中,它显示为“等待批准的更改”。
// Define new awaiting status
function my_custom_post_status(){
register_post_status( \'awaiting\', array(
    \'label\'                     => _x( \'Changes Awaiting Approval\', \'custom-post-type\' ),
    \'public\'                    => true,
    \'exclude_from_search\'       => false,
    \'show_in_admin_all_list\'    => true,
    \'show_in_admin_status_list\' => true,
    \'label_count\'               => _n_noop( \'Changes Awaiting Approval <span class="count">(%s)</span>\', \'Changes Awaiting Approval <span class="count">(%s)</span>\' ),
   ) );
 }
add_action( \'init\', \'my_custom_post_status\' );
 关键是,这是一种公共状态类型。
然后,我强制特定用户通过更新发布过程结束时的挂钩将发布状态更改为新状态。。。
function published_to_pending( $post_id ) {
    global $post, $current_user, $wp_meta_boxes ;
    if ( !is_object( $post ) )
        $post = get_post( $post_id );
    if ( !current_user_can( \'edit_post\', $post_id ) )
        return $post_id;
    // check for specific user that needs this publish to pending. otherwise exit
    if (get_current_user_role()!="custom-user-role"){
        return;
    }
    if ( $post->post_status=="publish" ) {
        global $wpdb;
        $result = $wpdb->update(
            $wpdb->posts,
            array( \'post_status\' => "awaiting" ),
            array( \'ID\' => $post_id )
        );
    }
}
add_action( \'post_updated\', \'published_to_pending\', 13, 2 );
function get_current_user_role() {
    global $wp_roles;
    $current_user = wp_get_current_user();
    $roles = $current_user->roles;
    $role = array_shift($roles);
return $role;
}
 请注意,通过“save\\u post”挂钩更新post状态的一种非常常见的方法对我没有好处。这是因为我意识到使用这个钩子无法保存与帖子正确连接的元数据,这破坏了我的AdvancedCustomField属性。
最后在单曲的前端。php页面查看我的条目时,我会检查帖子状态,如果状态为==“waiting”,我会手动执行$wpdb查询,以获取帖子的先前版本及其相关元属性。我希望这对其他人有用。