WordPress 评论添加评论之星

不说别的的直接切入主题

注:此方法仅适用于自定义评论列表的主题中。

将以下代码放置Fuctions.php中,

<code>
function get_author_class($comment_author_email,$user_id){
    global $wpdb;
    $adminEmail = get_option('admin_email');
    $author_count  =  count($wpdb->get_results(
    "SELECT comment_ID as author_count FROM  $wpdb->comments WHERE comment_author_email = '$comment_author_email' "));
    if($comment_author_email ==$adminEmail) 
        echo '<a class="vp" target="_blank" href="http://ceezi.com" title="这是傻逼博主"></a>';
    if($user_id!=0 && $comment_author_email !=$adminEmail) 
        echo '<a class="vip" target="_blank" href="" title="听!我在说认证用户"></a>';
    if($author_count>=0 && $author_count<10 && $comment_author_email !==$adminEmail) 
        echo '<a class="vip1" target="_blank" href="" title="亲,博主才刚刚认识你!"></a>';
    else if($author_count>=10 && $author_count<20 && $comment_author_email !==$adminEmail) 
        echo '<a class="vip2" target="_blank" href="" title="亲,这是热心围观群众!"></a>';
    else if($author_count>=20 && $author_count<30 && $comment_author_email !==$adminEmail)
        echo '<a class="vip3" target="_blank" href="" title="亲,这是资深水王!"></a>';    
    else if($author_count>=30 && $author_count<40 && $comment_author_email !==$adminEmail) 
        echo '<a class="vip4" target="_blank" href="" title="亲,这不是QQ啊!"></a>';    
    else if($author_count>=40 &&$author_count<50 && $comment_author_email !==$adminEmail) 
        echo '<a class="vip5" target="_blank" href="" title="亲,数据库都让你刷爆了"></a>';    
    else if($author_count>=50 && $author_count<100 && $comment_author_email !==$adminEmail) 
        echo '<a class="vip6" target="_blank" href="" title="亲,数据库真的不行了~"></a>';    
    else if($author_count>=100 && $comment_author_email !==$adminEmail) 
        echo '<a class="vip7" target="_blank" href="" title="亲,法律已经无法阻挡你回复了。"></a>';    
}
</code>

将以下代码丢至Style.css中

<code>
.vp,.vip,.vip1,.vip2,.vip3,.vip4,.vip5,.vip6,.vip7{background: url(images/vip.png) no-repeat;display: inline-block;overflow: hidden;border: none;}
.sb{backgroun:url(images/vip.png) no-repeat;width 16px;height:16px;}
.vp{background-position:-495px -3px;width: 20px;height: 20px;margin-bottom: -7px;margin-left:2px}
.vip{background-position:-515px -2px;width: 15px;height: 16px;margin-bottom: -3px;}
.vip1{background-position:-1px -2px;width: 20px;height: 16px;margin-bottom: -3px;}
.vip2{background-position:-63px -2px;width: 20px;height: 16px;margin-bottom: -3px;}
.vip3{background-position:-144px -2px;width: 20px;height: 16px;margin-bottom: -3px;}
.vip4{background-position:-227px -2px;width: 20px;height: 16px;margin-bottom: -3px;}
.vip5{background-position:-331px -2px;width: 20px;height: 16px;margin-bottom: -3px;}
.vip6{background-position:-441px -2px;width: 20px;height: 16px;margin-bottom: -3px;}
.vip7{background-position:-611px -2px;width: 20px;height: 16px;margin-bottom: -3px;}
</code>

点击这里查看样式背景图片,请将图片另存为vip.png,放到你主题的images文件中。

在fuctons.php中把以下代码添加至评论列表循环函数的用户名后面~~

<code><?php get_author_class($comment->comment_author_email,$comment->user_id)?></code>

此文章转自http://ceezi.com/archives/292.html;大发博客~

9 thoughts on “WordPress 评论添加评论之星
  1. I do not know whether it’s just me or if everybody else
    encountering problems with your blog. It seems like
    some of the text in your content are running off the screen. Can somebody else please comment and let
    me know if this is happening to them too? This might be a issue with my web browser because I’ve had
    this happen previously. Appreciate it

Comments are closed.

添加一条新回复 回到顶部

亲爱的,主人已经关闭了这篇文章的评论 。