Articles Comments

Marco Luthe Online! » WordPress Stuff » How To Highlight A Comment From The Author

How To Highlight A Comment From The Author

I have seen many blogs where the author’s comments are shown in a specific way. This makes sense if you – as the author – are answering specific questions. I have seen this on many plugin sites. Marking your comments makes it easier for your visitors to see important answers.

Inspired by the “Author Highlight” plugin for wordpress, I put some simple code into the loop of my comments.php which shows a “This is a comment by the weblog author” note below the date and time of the post:

<?php if(strcasecmp($comment->comment_author_email, 'youraddress@yourhost') == 0)
{
echo "<span style='color:blue; font-weight:bold'>This is a comment from the weblog author.</span>";
}
?>

[Update from 2008-06-24]

Matt Cutts actually describes a nicer different method by identifying the author’s ID in this post. [Update] That only works if you are logged in while commenting – otherwise, the user_id is “0″ and the highlighting won’t show.

Filed under: WordPress Stuff · Tags: , ,

  • It is a great way and really eye catching though... I am wondering if it is compitable with WP 2.7 Beta as well. Thanks alot, regards
  • thanks dude
  • Ok, here it is. I have slightly changed the CSS, so that by now, you should see a thick border and a light yellow as background color, whereas comments from visitors have a thin border and either white or grey as background color.
  • You should leave a comment so we can see. ;)
blog comments powered by Disqus