说到这个wordpress复兴可见的功用,小编早在多年前就尝试过,然则会有一些问题,比方运用多说致使复兴后,不能马上显现内容,所以就取消了这个功用,然则如果是用wordpress自带批评模块的话,那末这个功用,可谓是秒回秒可见哈!
下面我们直接说教程吧
这块,我就不引荐人人用什么插件了。完整到场代码即可OK!
在wordpress主题文件的functions.php内到场以下代码:
function reply_to_read($atts, $content=null) {
extract(shortcode_atts(array("notice" => '<p class="reply-to-read">温馨提醒: 此处内容须要<a href="#respond" title="批评本文">批评本文</a>后才检察.</p>'), $atts));
$email = null;
$user_ID = (int) wp_get_current_user()->ID;
if ($user_ID > 0) {
$email = get_userdata($user_ID)->user_email;
//对博主直接显现内容
$admin_email = "[email protected]"; //博主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复兴可见的功用了!
[@reply]批评可见的内容[@/reply]
或许
[@reply notice="自定义的提醒信息"]批评可见的内容[@/reply]
人人注意下,小编为了让代码展示出来,在代码里加了@,人人在运用的时刻把@去掉!functions.php内的代码仅替代邮箱即可!!!

评论列表