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 } ?>
-
WordPress函数:translate_nooped_plural 翻译并注册字符串WordPress函数:translate_nooped_plural 翻译并注册字符串
-
WordPress函数:number_format_i18n 数字国际化WordPress函数:number_format_i18n 数字国际化
-
WordPress函数:date_i18n 日期国际化WordPress函数:date_i18n 日期国际化
-
WordPress函数:esc_html_e 转义翻译的字符串并显示WordPress函数:esc_html_e 转义翻译的字符串并显示
-
WordPress函数:esc_attr_e 属性转义、翻译、显示WordPress函数:esc_attr_e 属性转义、翻译、显示
-
WordPress函数:esc_attr_x 带上下文的转义属性,翻译显示WordPress函数:esc_attr_x 带上下文的转义属性,翻译显示
暂无评论,抢个沙发...