VPS参考、测评、推荐
分享你关注的VPS主机优惠信息

WordPress网站如何设置评论回复可见内容?WordPress评论回复可见代码教程分享

WordPress网站如何设置评论回复可见内容?WordPress评论回复可见代码教程分享

可以看出,这个功能在一些上经常可以看到。如果用自己的,不是很好,所以我用了一段时间,但效果不理想,我取消了。鉴于部分站长朋友的需求,本文将与大家如何在WordPress中设置评论和回复指定内容的可见性。

WordPress网站如何设置评论回复可见内容?WordPress评论回复可见代码教程分享

很简单,在当前网站下的functions.php文件中添加如下代码:

/**  * WordPress评论回复可见代码  * https://.caogenba../66279.html  */  function reply_to_read($atts, $content=null) {               extract(shortcode_atts(array("notice" => '

温馨提示: 此处内容需要评论本文后才能查看.

'), $atts));
$email = null; $user_ID = (int) wp_get_current_user()->; if ($user_ID > 0) { $email = get_userdata($user_ID)->user_email; //对博主直接显示内容 $admin_email = "xxx@xxx.com"; //博主Email if ($email == $admin_email) { return $content; } } else if (isset($_COOKIE['comment_author_email_' . COOKIEHASH])) { $email = str_replace('%40', '@', $_COOKIE['comment_author_email_' . COOKIEHASH]); } else { return $notice; } if (empty($email)) { return $notice; } global $wpdb; $post_id = get_the_ID(); $query = "SELECT `comment_ID` FROM {$wpdb->comments} WHERE `comment_post_ID`={$post_id} and `comment_approved`='1' and `comment_author_email`='{$email}' LIMIT 1"; if ($wpdb->get_results($query)) { return do_shortcode($content); } else { return $notice; } } add_shortcode('reply', 'reply_to_read');

注意:需要将代码中的地址替换为博主自己的,这样就不用评论了,就好!

WordPress评论回复可见示例:

温馨提示:为了避免资源链接被和谐,此处内容需要 评论本文 后 刷新本页 才能查看!

那么我们以后发表的时候,只需要加一个,就可以让回复对指定的内容可见。代码显示如下:

[rep删除ly]    评论可见的内容    [/rep删除ly]

[rep删除ly notice="自定义的提示信息"]    评论可见的内容    [/rep删除ly]

可见,用户操作中的回复其实是一个比较有争议的功能。如果你用得好,它可以为网站带来更多的活跃用户。如果使用不好,会让用户反感,甚至用户会选择直接。它通常用于。至于草根吧或以后都使用。毕竟这也违背了写的初衷。

:WordPress网站如何设置评论回复可见内容?WordPress评论回复可见代码教程,https://vps.caogenba.com.com/66279.html

赞(0) 打赏
未经允许不得转载:草根吧VPS_最新VPS信息参考 » WordPress网站如何设置评论回复可见内容?WordPress评论回复可见代码教程分享
分享到: 更多 (0)

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址