您可以使用这些条件仅向具有角色的登录用户显示私人帖子contributor
. 现在你只需要发帖子private
使投稿人可以使用该帖子。
<?php
if ( have_posts() ) : while ( have_posts() ) : the_post();
$private = get_post_custom_values("private");
if (isset($private[0]) && $private == "true") {
if ( current_user_can( \'contributor\' ) ) { //passing role to it may sometime not work
the_title();
the_content();
} else { // text to show instead the post
echo \'this post is private, only contributor can view it\';
}
} else { // this is visible to all
the_title();
the_content();
}
endwhile;
endif;
?>