Highlight the Author’s Comments
I always neglect my personal site when working on other consuming side-projects. Lately I've been hanging out at the wordpress support forums, because my latest project involves wordpress. When I go there to search for answers, I invariably spend a minute and answer a couple of recent threads.
The mood of my reply to those threads varies with the quality of the answer I've just found for myself. Not intentionally of course, it's just one of those cosmic-balance things :)
This is another in a burst of wordpress posts for me lately, partly because I'm hacking around with it, but also because a few of my most recent visitors have come from the wordpress forums via posts I've made there.
Christine asked me about making her own comments stand out from everyone else's. This is one of the most widely-embraced features of all, I think, and with good reason. It really makes it easy to find the official word amongst all the chatter (not that I have a big problem with excessive chatter here, mind you).
I directed her to a plugin called Highlight Author Comments, but plugins aren't really necessary for this sort of thing, if you're comforable with editing your theme.
The basic idea is to take the main comment element in your design, and give it a different CSS class. This allows you to differentiate between one type of comment and another. It's quite easy, if you can find where your particular theme puts this information in the first place, as all themes are different, this part is up to you, unfortunately.
Your theme's comment.php will is the place to look. You might find either a div tag, or a list-item tag with the style of your comments applied to it, like this perhaps:
<li class="comment">
Our aim is to change that for the comments made by the post author, so it looks like the following, but only for that specific comment:
<li class="author_comment">
To do that, we'll need to put a little wordpress php magic in place of the 'class' attribute.
<?php if($comment->comment_author_email == get_the_author_email()) $comment_class = 'author_comment'; else $comment_class = 'comment'; ?> <li class="<?php echo $comment_class; ?>">
Now in your CSS file, just take the existing .comment definition and make a new one called .author_comment, which you can then change accordingly.
.comment {
border: 1px solid blue;
background-color: #88ccff;
}
.author_comment {
border: 3px solid red;
background-color: #ffcccc;
}
Of course yours will be a bit more complex, but that's the general idea. Given the differences in themes, it's hard to be overly specific so something like this is best suited to those who are already up to their elbows in theme customisation. For the rest, there's always that plugin I mentioned above.
You can get as creative as you like really, and it works on multi-author blogs just as well as it will on your personal blog, bearing in mind that if you're not the author of a post, your comments will not appear as though they're special, even though you might be the owner of the site and a total rock star.
Trust me, you'd have been bored if I didn't pad this post out with some back-story.
PermaLink
Comments (31)






