为WordPress指定内容设置评论回复,说明这个功能在一些网站上经常看到。如果用自己的网站很好,用了一段时间,效果不理想,就取消了。
鉴于一些站长朋友的需求,本文将与大家分享WordPress指定内容来设置评论回复白天可见的方法。
方法很简单。将以下代码添加到当前网站主题下的functions.php文件中:
函数reply_to_read($atts,$content=null) {
extract(short code _ atts(array(' notice '='
),$ atts));
$ email=null
$ user _ ID=(int)WP _ get _ current _ user()-ID;
if ($user_ID 0) {
$ email=get _ user data($ user _ ID)-user _ email;
//直接向博主显示内容
$ admin _ email=' xxx @ xxx.com//博主邮件
if ($email==$admin_email) {
返回$ content
}
} else if(isset($ _ COOKIE[' comment _ author _ email _ ')。COOKIEHASH])) {
$email=str_replace('@ '、' @ '、$ _ COOKIE[' comment _ author _ email _ '。COOKIEHASH]);
} else {
返回$ notice
}
if(空($email)) {
返回$ notice
}
global $ wpdb
$ post _ ID=get _ the _ ID();
$ query=' SELECT ` comment _ id ` FROM { $ wpdb-comments } WHERE ` comment _ post _ id `={ $ post _ id }和` comment_approved`='1 '和` comment _ author _ email `=' { $ email } ' LIMIT 1 ';
if ($wpdb-get_results($query)) {
return do _ short code($ content);
} else {
返回$ notice
}
}
add_shortcode('reply ',' reply _ to _ read ');
注意:你需要把代码里的邮箱地址换成博主自己的,这样就不用评论了,直接保存!
那么以后我们发表文章的时候,只需要添加短代码,即可以实现唐山百度排名,回复可以设置为指定内容。代码如下:
[回复]
对可见内容进行评论
[/回复]
或者
[回复通知='定制提示信息']
对可见内容进行评论
[/回复]
结论:在用户操作中,回复其实是一个有争议的功能。如果用的好,可以给网站带来更多的活跃用户,但是用的不好,会让用户产生反感,甚至用户会选择直接关闭。论坛上常用,白天和以后都不会用博客,违背了写博客的初衷。