WordPress登录可见评论模块

追格官方小助手/ 2022年03月11日/ WordPress/ 浏览 1457

WordPress登录后方可见评论模块,我们只要用到是否登录的WordPress函数is_user_logged_in(),然后用判断函数把评论模块包裹起来即可。


操作流程如下:

WordPress模板文件single.php,找到类似:


if ( comments_open() || get_comments_number() ) :comments_template();endif;


改成:


if ( is_user_logged_in()){if ( comments_open() || get_comments_number() ) :comments_template();endif;}


其他主题方法类似,如:


<?php if ( is_user_logged_in()){ ?><?php if ( comments_open() || get_comments_number() ) : ?><?php comments_template( '', true ); ?><?php endif; ?><?php } ?>


发表评论

暂无评论,抢个沙发...

客服 工单