• Blogging News
  • Blogging Resource
  • Blogging tips
  • Blogging tutorials
  • Interview
  • Links Post
  • Personal logs
  • Reviews
  • WordPress Tips
  • WordPress Guide — 如何Highlight自己的评论

    在评论中将博主自己的评论高亮(highlight)、与其他评论区分开来有助于读者和评论者快速的找到作者的补充观点和回复,今天的wordpress guide将介绍如何将blogger自己的评论高亮.
    以前比较多的做法是在代码中添加这样的功能: 检查评论者的email是否是作者的email地址,如何是的话,认为是博主的评论,highlight此评论。但这样的做法并不是很好,因为任意评论者只要知道作者的email就可以在评论时使用此mail使自己的评论高亮。

    今天在wordpress论坛看到一种更好的做法:检查他们的 user id,看是否是博主的user id,如何是的话,highlight这条评论。

    具体的方法也很简单,下面以一个普通的wp主题为例:

    1.打开你的comment.php找到以下代码:

    <li class=”<?php echo $oddcomment; ?>” id=”comment…

    将其改为:

    <li class=”<?php
    /* Only use the authcomment class from style.css if the user_id is 1 (admin) */
    if (1 == $comment->user_id)
    $oddcomment = “authcomment”;
    echo $oddcomment;
    ?>” id=”comment…

    2.然后再你的style.css中为你的authcomment定义一种特殊的颜色

    .authcomment {
    background-color: #B3FFCC !important;
    }

    这样你自己的评论就会与其他评论区分开来了,关于user id,可以在后台–user中找到,如图:

    user.gif

    不同主题的comment.php会有点差异,不过基本大同小异,以上的方法只是提供了一种思路,跟大家分享一下:)

    Related posts

    8条留言

    (Required)
    (Required, not published)

    Who is behind this blog?

    My name is Jacky,a college student in China at present.Blogging is one of my hobbies.I ran this blog to bring in useful blogging tips and skills from the top bloggers in foreign countries since I find there still remains a gap between our chinese blogs and foreigners'.I also want to help the greenhands who have just started blogging and may be not familiar with wordpress.I am looking forward to being your friend.Feel free to connect with me.