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

Posted by

Hi,

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:
<liadmin@yourblog.com”) echo ‘author’; else echo $oddcomment; ?> item”
id=”comment-<?php comment_ID() ?>”>

You need to modify admin@yourblog.com 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 == “author2@yourblog.com”) echo ‘author2’; else if
$comment->comment_author_email == “author3@yourblog.com”) 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 author2@yourblog.com 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!

Thanks,

Shane G.

Leave a Reply

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