Highlighting Author Comments in Wordpress

So one of the cooler Wordpress hacks is allowing the articles authors comments to be highlighted. This helps the authors suggestions and comments stick out from the rest, allowing a more useful discussion. Below are two methods of achieving this effect.

So here it is for all of your Wordpress hacking needs.

First thing you are going to need to do is open your current themes stylesheet. To do this log into your admin control panel, typically located at http://yourblogurl.com/wp-admin. From there click on Design Tab followed by the Theme Editor link. Once in the theme editor you’ll see links along the right and you should see a file named style.css (this is a required file for Wordpress Themes so it’ll be standard for all your themes). Click on the file and it’ll bring it up in the editor for your edit.

add this code anywhere in your stylesheet:
.authorcomment {
background: #131313;
}

Now this code can be edited to your liking based on the CSS look you are going for.

Next you’ll need to need to open up your comments.php for editing. (follow the sames steps you used to find the style.css).

You should find the following code:

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

And you’ll want to replace it with this:

<li <?php if ($comment->user_id == 1){ $oddcomment = 'authorcomment'; } echo "class=\"" . $oddcomment . "\"";     ?>id="comment-<?php comment_ID() ?>">

Now if you wanted the other of the post to be dynamic (say you share a blog with multiple authors) you would use this instead of the code above:

<li <?php if ($comment->user_id == $post->post_author){ $oddcomment = 'authorcomment'; } echo "class=\"" . $oddcomment . "\"";     ?>id="comment-<?php comment_ID() ?>">

Thats it! Enjoy.

11 Responses to “Highlighting Author Comments in Wordpress”

  1. Php Website Editor Says:

    Good site I \”Stumbledupon\” it today and gave it a stumble for you.. looking forward to seeing what else you have..later

  2. Julián Rodriguez Orihuela Says:

    Great job!

    I leave my version here, which marks any registered user’s comment as class ’staff’:

    <li <?php if ($comment->user_id != 0){ $oddcomment = ‘class="staff" ‘; } echo $oddcomment; ?>id="comment-<?php comment_ID() ?>">

  3. Saniska Says:

    Присоединюсь к предыдущим комментариям и буду следить за дальнейшими обновлениями

  4. Starks Says:

    Побольше бы таких работ.

  5. Olegreze Says:

    Основная задача Яндекса — давать ответы на вопросы пользователей!

  6. сесшоп мэн Says:

    спасибо

  7. Bariton Says:

    Thanks, article written ochentochno. In other words, and not say.

  8. cb affiliate loophole Says:

    What a great post. I just love it - it picks up the immediacy and yes, even intimacy, we get from participating in the conversation you speak of. Such good advice about tracking comments. I tried to install CoComment but something happened and I didn’t go through with it. But I will try again now. I just found out about del.icio.us netwrok badges we can put on our blogs and I think this would also add to the value of the connectivitiy

  9. Styletrend Says:

    Thanks to the author for the answers to all questions. In fact, learned from the article many new and useful. That’s only until the end and did not understand some nuances.

Trackbacks

  1. New Wordpress Hack | CalebAWhite.com
  2. Quake Media Highlighting Author Comments in Wordpress | Outdoor Ceiling Fans

Leave a Reply