How To Set Different Style For Author’s Comment In WordPress Blog

Posted by


Many wordpress users style the author comment for their blog which will differentiate the comment from others. You can easily adjust your wordPress theme to display different styles for each author. For that you need to adjust the code of comments.php file of your theme. For that you need to perform these steps:

1) Open comments.php file of your theme.

Find this code:
<li id=”comment-<?php comment_ID() ?>”>

Replace with:
<”) echo ‘author’; else echo $oddcomment; ?> item”
id=”comment-<?php comment_ID() ?>”>

You need to modify to reflect the primary blog author’s e-mail address. This will tell wordPress to check each comment to see if you are the author. Now, go to CSS stylesheet (style.css) and add the commands you would like to use for your author comments. You need to use .author to style author comments. I recommend pulling your standard comment code, then adjusting the colors to look different on your comments. You can also add a logo through your stylesheet.

<li) echo ‘author’; else if ($comment-
>comment_author_email == “”) echo ‘author2’; else if
$comment->comment_author_email == “”) echo
author3′; else echo $oddcomment; ?> item” id=”comment-<?php comment_ID()

When the comment includes that e-mail it will use the .author style from the stylesheet. The second author will use .author2 for their stylesheet and replace with the 2nd author’s e-mail, etc. Any comments that do not include one of the above e-mails will use the default styles.

That’s it!


Shane G.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.