Design Oahu

Web design blog from the middle of the pacific.

WordPress Tutorial: How to style author comments

I have seen several wordpress blogs recently that uniquely style the author’s comments. This is a great usability technique, so that you can easily distinguish their posts. This comes in handy when visiting a new blog that perhaps you do not know the author’s name. All you do is simply compare the comment author’s email address with your own. This little snippet of code does just that, and specifies a class of “authorcomment” within the opening list item tag of the comment. You will want to place this code in your comments.php file. The code should go within the foreach comment loop and just before the end of the opening list item tag. If you have the default unmodified WordPress theme this will be on line 29. The finished product should like something like this:

<li <?php echo $oddcomment; ?>id=”comment-<?php comment_ID() ?>”

<?php if($comment->comment_author_email == ‘email@example.com’) : ?>

class=”authorcomment”

<?php endif; ?>>

Now all you have to do is add the look you want for your comments. I currently modified my style to have a light gray background by adding this to my style.css file:

.authorcomment{
background-color:#f5edd6;
}

You can now make your posts stand out from the crowd. To make it even easier to read the comments try moving the trackbacks out of the comments.

If you liked what you read you may be interested in subscribing to our RSS feed or email alerts. You may also want to read up about what RSS feeds are all about.

3 Comments

  1. Comment by Melissa on October 2, 2008

    Very good site! I like it! Thanks!

  2. Comment by Capone on January 21, 2009

    Прелесть! Я тоже мечтаю) Возьму - и сделаю… У меня получится. Спасибо, очень глубокая и позитивная статья.

  3. Comment by jeny79 on March 2, 2009

    Всегда можно найти компромиссы и прийти к общему решению. Если вам что-нибудь не нравится попробуйте что-нибудь другое.

Leave a Comment