如果你是WordPress开发的新手,我建议你使用这个插件https://wordpress.org/plugins/members/, 有一个选项允许您根据用户角色禁用内容,您还可以使用插件轻松创建角色。
至于你的问题:如果你不想让拥有订阅者角色的用户查看内容,我正在使用twentysixteen 以主题为例
// Start the loop.
if( have_post() ) :
while ( have_posts() ) : the_post();
/*
* Include the Post-Format-specific template for the content.
* If you want to override this in a child theme, then include a file
* called content-___.php (where ___ is the Post Format name) and that will be used instead.
*/
if( current_user_can( \'edit_posts\' ) ) :
// can accessed by contributor and the others but not subscriber
get_template_part( \'template-parts/content\', get_post_format() );
endif;
// End the loop.
endwhile;
endif;
“edit\\u posts”角色是订阅者没有的功能,您可以在此处查看有关角色和功能图表的更多信息
https://codex.wordpress.org/Roles_and_Capabilities#Capability_vs._Role_Table