highlight blog author in comments
Samstag, 20. Oktober 2007 um 12:52 Uhr Christian
entry written in English, because of the wider audience.
I recently saw blogs in which comments written by the blog author are highlighted, e.g. http://blog.us.playstation.com. Cool feature, eh? It’s easy to realize that in your own WordPress blog. Just change the template comments.php a bit.
Let’s say you have such a line in your comments.php:
<li id="comment-<?php echo $commentcount ?>" class="< ?php comment_type('comment','trackback','pingback');"> </li>
(example: blix theme)
Then you have to add the following to the class entry:
if (!empty($comment->user_id)) echo ' comment-highlight';
In this variant, all registered user are highlighted.
You may just want to highlight the real author of the entry:
if ( (!empty($comment->user_id) && $comment->comment_author_email == get_the_author_email() ) echo ' comment-highlight';
You could also think of playing around with the user level to devide users even more.
If you don’t have a class statement, you’ll have to add it. For example:
<li id="comment-<?php echo $commentcount ?>" if (!empty($comment->user_id)) echo 'class=\"comment-highlight\"'; ?>"> </li>
The finished line could look like this:
<li id="comment-<?php echo $commentcount ?>" class="< ?php comment_type('comment','trackback','pingback'); if (!empty($comment->user_id)) echo ' comment-highlight'; ?>"> </li>
after you modified the comments.php, you should add a fitting style to your css file depending on your template. I use the following:
.comment-highlight { border-bottom: #A3C159 solid 1px; border-top: #A3C159 solid 1px; background: #FFFFF0; }
A border and a changed background looks nice in my opinion and don’t emphasize the entry to much.
Have fun.
Artikel gespeichert unter: Verschiedenes
Ihr Kommentar
Folgende HTML-Tags sind erlaubt:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">
Trackback | PDF