Title: Admin Comments: Different CSS
Last modified: August 18, 2016

---

# Admin Comments: Different CSS

 *  [stumpcrash](https://wordpress.org/support/users/stumpcrash/)
 * (@stumpcrash)
 * [18 years, 6 months ago](https://wordpress.org/support/topic/admin-comments-different-css/)
 * [http://www.stumpcrash.com](http://www.stumpcrash.com)
 * I want to reply to my visitors who comment on my blog and I want the comment 
   structure (or the style) to be different when I’m logged in and I reply.
 * How do I do so?

Viewing 10 replies - 1 through 10 (of 10 total)

 *  [Kafkaesqui](https://wordpress.org/support/users/kafkaesqui/)
 * (@kafkaesqui)
 * [18 years, 6 months ago](https://wordpress.org/support/topic/admin-comments-different-css/#post-661292)
 * You can define a class (let’s say ‘comment-admin’) you can style in your theme’s
   style.css. In the comments loop (of your comments.php):
 *     ```
       <?php
       $comment_class = (1 == $comment->user_id) ? 'comment-admin' : 'comment';
       ?>
       ```
   
 * Make sure to change the `1` to the user ID of your login if different. Then where
   you want to insert the class (for example we’ll use a div, but it can be any 
   element you plan to modify):
 * `<div class="<?php echo $comment_class; ?>">`
 *  Thread Starter [stumpcrash](https://wordpress.org/support/users/stumpcrash/)
 * (@stumpcrash)
 * [18 years, 6 months ago](https://wordpress.org/support/topic/admin-comments-different-css/#post-661377)
 * <div class=”<?php echo $comment_class; ?>”>
 * Where will I place this?
 * In the loop?
 *  [Kafkaesqui](https://wordpress.org/support/users/kafkaesqui/)
 * (@kafkaesqui)
 * [18 years, 6 months ago](https://wordpress.org/support/topic/admin-comments-different-css/#post-661386)
 * As I note it is an example. You would want to echo $comment_class as a value 
   for ‘class’ on whatever HTML element you need to affect. This can be a div, and
   span, a paragraph (<p>) tag. Whatever.
 * But yes, it would certainly be in the comments loop of your comments template.
 *  [thomas-dk](https://wordpress.org/support/users/thomas-dk/)
 * (@thomas-dk)
 * [18 years, 6 months ago](https://wordpress.org/support/topic/admin-comments-different-css/#post-661408)
 * Why not keep it even more simple 🙂
 * `<div class="author-id-<?php echo $comment->user_id; ?>">`
 * And then just style `.author-id-1`
 *  [natalie](https://wordpress.org/support/users/natalie/)
 * (@natalie)
 * [18 years, 2 months ago](https://wordpress.org/support/topic/admin-comments-different-css/#post-661475)
 * I came across this thread in a search for something else, but I have a solution
   for anyone who has multiple blog authors.
 * This will allow you to set the class for a comment based on who wrote a post 
   instead of just the blog owner:
 * [Different Content for Different Authors](http://wp.nataliejost.com/dev/different-content-for-different-authors/)
 *  [wyldwolf](https://wordpress.org/support/users/wyldwolf/)
 * (@wyldwolf)
 * [18 years, 1 month ago](https://wordpress.org/support/topic/admin-comments-different-css/#post-661479)
 * I’m using the following:
 *     ```
       <?php// Comment loop
       if ($comments):
       	foreach ($comments as $comment):
       	// Test if Comment Author == Post Author
       		if ($comment->user_id == $post->post_author):
       			$CommentAuthorIsPostAuthor = True;
       		else:
       			$CommentAuthorIsPostAuthor = False;
       		endif;
   
       	// NoFollow sucks, we need an "alt" tag
       		$AuthorName = $comment->comment_author;
       		$AuthorURL = $comment->comment_author_url;
       		if ( ($AuthorURL == '') || ($AuthorURL == 'http://') ):
       			$AuthorData = "Comment by $AuthorName";
       		else:
       			$AuthorData = "Comment by <a href='$AuthorURL' alt='URL for comment author $AuthorName'>$AuthorName</a>";
       		endif;
       ?>
       ```
   
 * So this chunk of code does the following:
    1. Identify the author based on user id. This means you will only be identified
       as the author if are actually logged in. (keeping email high-jackers from being
       identified as the author erroneously).
    2. Allow for custom comment author links. In my case I’m adding an “alt” tag, and
       removing the “rel” tag.
 * Kevin
 *  [mr_director](https://wordpress.org/support/users/mr_director/)
 * (@mr_director)
 * [17 years, 9 months ago](https://wordpress.org/support/topic/admin-comments-different-css/#post-661527)
 * Is there any update to how to do this in the new WordPress? I don’t have a comment
   loop section in my theme I don’t think…
 *  [whooami](https://wordpress.org/support/users/whooami/)
 * (@whooami)
 * [17 years, 9 months ago](https://wordpress.org/support/topic/admin-comments-different-css/#post-661528)
 * > … I dont have …
 * yes, you do.
 *  [termserv](https://wordpress.org/support/users/termserv/)
 * (@termserv)
 * [17 years, 8 months ago](https://wordpress.org/support/topic/admin-comments-different-css/#post-661534)
 * Wow, thanks Thomas-DK! That is the simplest “different css”-trick I’ve seen! 
   🙂
 *  [danapalooza](https://wordpress.org/support/users/danapalooza/)
 * (@danapalooza)
 * [17 years, 7 months ago](https://wordpress.org/support/topic/admin-comments-different-css/#post-661536)
 * wyldwolf, can you give me an idea as to where this would go/what it would replace
   in 2.6’s **comments.php** file?

Viewing 10 replies - 1 through 10 (of 10 total)

The topic ‘Admin Comments: Different CSS’ is closed to new replies.

## Tags

 * [admin](https://wordpress.org/support/topic-tag/admin/)
 * [Comments](https://wordpress.org/support/topic-tag/comments/)
 * [css](https://wordpress.org/support/topic-tag/css/)

 * 10 replies
 * 9 participants
 * Last reply from: [danapalooza](https://wordpress.org/support/users/danapalooza/)
 * Last activity: [17 years, 7 months ago](https://wordpress.org/support/topic/admin-comments-different-css/#post-661536)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
