您可以尝试map_meta_cap
过滤器:
/**
* Uneditable posts/pages for editors
*/
add_filter( \'map_meta_cap\', function ( $caps, $cap, $user_id, $args )
{
// Edit to your needs:
$post_ids = [123, 234, 345, 456]; // Uneditable posts
$role = \'editor\'; // Uneditable by this user role
// Make given posts uneditable for the above user role:
if (
\'edit_post\' === $cap
&& isset( $args[0] )
&& in_array( $args[0], $post_ids )
&& current_user_can( $role )
)
$caps[] = \'do_not_allow\';
return $caps;
}, 10, 4 );
使某些页面/帖子不可编辑。