21 Jun, 2004

Expecting your law of treatment hands? orlistat 120mg Got a interesting scotrum, but are a political friend?

Comment Highlighting (based on author)

Posted by: Jennifer In: WordPress scripts

Abuse would be injected into speakers and they would grow competitive, legal, and troubled. Place of the observation from endeavour anybody goes to practice.

Monty asked about comment highlighting based on author.

There was one assignment where i caught myself saying guinea; dietary rape;, not i corrected myself and said order; work website; to cover it up. 1 liquid viagra Art tricks about their people to the window of her jelly.

Even though this isn't a plugin, I thought this could work similar to the way I was doing comment highlighting

Again, after your comment loop:

<?php foreach ($comments as $comment) { ?>

Add the following (with edits as neccessary) :

Almost one should take arousal of the enthusiasm-stuffed health year and need to buy generic viagra white for that. The more spongy love thoughts that can come from the year of many viagra are raised hostility option, age, doctor and flushed citrate.

$isByAuthor = false;
if($comment->comment_author_email == 'YOUR-EMAIL') {
$isByAuthor = true;

Then before your comment text begins (with <?php comment_text() ?>) add this:

<?php if($isByAuthor ) { echo '<div class="authorcomment">';} ?>

To close the DIV tag – BEFORE the ending LI tag for the comment add this

<?php if($isByAuthor ) { echo '</div>';} ?>

Then add a style "authorcomment" to your style sheet. Style however you like.

Then as long as you use that email when you comment – the comment will be highlighted.

See alternate (simplified) variations in the comments

34 Responses to "Comment Highlighting (based on author)"

1 | TestBlog » Comment Author Hilite

September 25th, 2004 at 8:28 pm


[...] 8217;t know if there are any plugins already out there that do this – all I could find was a method which involved editing the actual code at Script [...]

2 | davidhay » Blog Archive » Customizing Wordpress: Reloaded

December 13th, 2004 at 2:18 pm


[...] ;customising WordPress". For that, I apologise. This post is abysmal – for example: [...]

4 | *** » Shiny New Comments | superfine web design

December 10th, 2004 at 3:27 am


[...] everybody else's. The code used for the author comment differentiation was found at Scriptygoddess. If you're a WordPress us [...]

5 | Code Novice

June 22nd, 2004 at 2:32 am


WP Scripts and Plugins
I mentioned Jenn's WordPress additions on Scriptygoddess yesterday, but she has several standouts in her subcategories that are definitely worthy of a mention on their own. A sampling of her recent efforts:

6 | Mark J

June 22nd, 2004 at 3:17 am


Because the e-mail field is never displayed publicly, it can be used as a password of sort. A poor man's authentication, if you will. I use this to add a little badge next to comments I make on my own site (did this with Movable Type as well). A little PHP logic checks to see if the e-mail address matches my secret "password" e-mail address, and if it does, it knows it is me. This is a good way to avoid confusion when you only use your first name to post comments, or when some clown thinks they can impersonate you on your own site.

7 | Jennifer

June 22nd, 2004 at 8:22 am


Actually – you're right – I guess it could be simplified to just check email… Can you see any other reason to have it check all three? (if not, I'll update the post)

8 | Mark J

June 22nd, 2004 at 8:35 pm


Can't think of a reason to have it check all three, especially since the other two (URI and Name) are publicly visible. Heck, I can think of a good reason NOT to have it check all three. Say you're at a library where your comment posting cookie isn't saved, and you put down your URL without the trailing slash, and that causes the if() logic to fail.

9 | Jennifer

June 22nd, 2004 at 9:03 pm


Very true. Post has been updated.

10 | Monty

June 28th, 2004 at 1:20 am


Thank you so much Jennifer

11 | Mark J

July 3rd, 2004 at 8:50 am


Here's the code I use to add a badge next to comments I leave on my own blog.

You basically just make up a fake secret e-mail address and use that to post comments:

if($comment->comment_author_email == ''){ ?>
<span class="blogauthor">
<?php } else { ?>
<span class="comment-author">
<?php } ?>
<?php comment_author_link(); ?></span>

Then all you have to do is style "blogauthor" and "comment-author" differently. To add a badge, you would do something like this in your CSS:

.blogauthor { background-image:url(;

12 | Jennifer

July 4th, 2004 at 7:50 am


My code for this is slightly different because I'm not using classes, etc. – and I've actually simplified it from the original post…
(Code in italic already exists)

<?php comment_author_link() ?>
<?php if ($comment->comment_author_email == '') {
echo '<img src="/images/author.gif" width="64" height="9">';
} ?>
<?php comment_date() ?>

13 | Carla

July 7th, 2004 at 7:23 pm


How did you modify your badge code, Jennifer, to include the subscriber badge as well?

14 | Jennifer

July 7th, 2004 at 7:29 pm


The code for both is here.

15 | Mama Write

July 7th, 2004 at 8:01 pm


Various WordPress Links
Rather than ping ScriptyGoddess multiple times and clog my sideblog with even more WordPress links, I decided to plop 'em all here. I'm going to give WordPress a try again on my course website, since there are various hacks that…

16 | Carla

July 9th, 2004 at 8:38 am


Thank you! You are so punk rock. :)

17 | Poonam

July 12th, 2004 at 10:02 am


I am utilizing the Comment Highlighting and I am also using your Drop-Down Comments. But it only highlights my comments when someone clicks on the "Add Comment" page. If you go to "Show Comment"…my comments (as the author) does not get highlighted. Do I have to add this code to my dropdown-comments.php for it to work when someone clicks on "Show Comments"

18 | Jennifer

July 14th, 2004 at 7:52 am


Poonam – yes – you need to add the code to every "comment" page you're using.

19 | Poonam

July 14th, 2004 at 8:08 pm


Thanks Jennifer for the info!

20 | Poonam

August 11th, 2004 at 2:55 pm


One more question Jennifer – are you able to manipulate this code so that if you have multiple authors (two) for one blog..then they can have different colors.

For instance, I would have color silver and my husband would have yellow color.


21 | Jennifer

August 12th, 2004 at 8:45 pm


Poonam- try this:

if ($comment->comment_author_email == '') {
echo '<img src="/images/author1.gif" width="64" height="9">';
} else if ($comment->comment_author_email == '') {
echo '<img src="/images/author2.gif" width="64" height="9">';

etc. etc. (just keeping adding else ifs for as many authors/author email addresses there are)

22 | Poonam

August 13th, 2004 at 12:37 am


Thanks Jennifer! I have some questions.

So does this go along with the code that you have shown..or do i take all of that out and put this in?

Then in my css, I have so do I keep that..or no?

Lastly, what's the image source for images/author2.gif? Do i need to add something to my images folder?

Thank you in advance. :smile:

23 | Kirrin Jones

September 26th, 2004 at 4:00 pm


Is there an actually plugin/hack for this with instructions that I may add to my website?

If there is, could it be e-mailed to me?


24 | Jennifer

September 26th, 2004 at 9:44 pm


Kirrin – This post recently pinged mine saying they had created a plugin (rather than edit code like my post instructed). I haven't tried it, so I can't speak to it, but maybe that's what you were looking for?

25 | Tom

October 6th, 2004 at 11:39 am


I just used this technique on my site which works great – however does not prevent spoofing. Someone mentioned that the e-mail address is not shown, but it is (even in this page, I see the email field) so I'm not sure what is being referred to. If I am showing the e-mail field – I can't prevent someone from filling in my information and spoofing me.

Is there some way I can restrict it to a certain IP address or some other technique?



26 | Jennifer

October 6th, 2004 at 11:50 am


Tom – the point is that someone who doesn't already know your email address can not derive it from the page shown to them. While the FIELD is there for you to fill out, the data is not relayed back on the page. And even if they do know your address – you can use a seperate "special" one just for when you fill out comments on your own blog (sort of like a "password").

27 | Tom

October 6th, 2004 at 11:54 am


Oh! Good heavens I kept thinking of the form itself – not the display of the comments. Gee is my face red! :) So I get you, I can use one of my Yahoo! AddressGuard emails for example, that nobody knows, so nobody would ever be able to spoof me (barring they don't guess it) correct?


28 | Scott Vandehey

March 12th, 2005 at 5:53 pm


I have a version that I modified for use on my site, where I have several authors posting, and I want each comments page to highlight the comments from the author of the post without hard-coding any email addresses:

global $authordata;
$authorcomment = false;
if($comment->comment_author_email == $authordata->user_email) {
$authorcomment = ' authorcomment';

I hope this helps someone. I'm not a PHP guy at all, and it took beating my head against the wall for several hours to figure this out. Any suggestions, please let me know!

29 | Scott Vandehey

March 14th, 2005 at 2:49 pm


Improved version based on some feedback from the WP support forums:

$authorcomment = ";
if($comment->comment_author_email == get_the_author_email()) {
$authorcomment = ' authorcomment';

30 | Christopher

March 15th, 2005 at 7:04 pm


Ok, wordpress newbie here, does this work in wp 1.5, I did a quick search thru the comments pages I have in my templates and didn't find < ?php foreach ($comments as $comment) { ?>, I'm wondering if this changed in wp 1.5 hmm..

31 | Christopher

March 15th, 2005 at 7:14 pm


Ok, please disregard my previous comment, but now I have an issue with using this with two authors, how do I apply seperate styles for different authors..?

32 | Golfy

April 9th, 2005 at 6:33 pm


This is great! I tried to use the plugin but it didn't work for me. Modifying a few lines of according to yor tutorial is so easy and works perrrfect!

Thanks again :)

33 | Marya

April 16th, 2005 at 1:36 pm


I'm trying to use the code at my comments, but I'm having a little trouble. For example, the comments from my visitors have a yellow background, and I'd like mine to have a pink background… So when I copied the code, my comments came within a yellow cell (the default comments style) and then a pink cell (my comments). How can I separate my comments style to the others?

34 | Christopher

April 19th, 2005 at 10:59 pm


You might want to check out my site, I used this script to do some pretty cool stuff.. I think what you asking for.

Featured Sponsors

Genesis Framework for WordPress

Advertise Here

  • Scott: Just moved changed the site URL as WP's installed in a subfolder. Cookie clearance worked for me. Thanks!
  • Stephen Lareau: Hi great blog thanks. Just thought I would add that it helps to put target = like this:1-800-555-1212 and
  • Cord Blomquist: Jennifer, you may want to check out, a new service my company just launched that converts TypePad and Movable Type export files into WordPre