如何让wordpress的内容回复可见呢
小西整理了一下网上列出来的方法,也测试过了,发过以下这些代码在wordpress中能够实现回复后刷新可见!
代码如下
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
//评论可见 function reply_to_read($atts, $content=null) { extract(shortcode_atts(array("notice" => '<span class="vihide">抱歉,隐藏内容 <a href="#respond" title="回复">回复</a>后刷新可见.</span>'), $atts)); $email = null; $user_ID = (int) wp_get_current_user()->ID; if ($user_ID > 0) { $email = get_userdata($user_ID)->user_email; $admin_email = "xinyewl@qq.com"; 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'); |
还要添加以下css代码哦
点击下载css代码
点评
小西觉得,如果采用内容回复可见,那对于真心想要资源的朋友肯定会回复的~如果当个白飘档,自然不愿意回复,也要想想发贴人才行呀~人家能发出来了,也算是分享拉~给个回复又有什么呢?作者觉得有人看,你得到自己想要的~真是一举两得的事情。wordpress的内容回复可见确实是个有用的小插件~