Title: Different backgrounds for comments&#8230;
Last modified: August 18, 2016

---

# Different backgrounds for comments…

 *  Resolved [ythibodeau](https://wordpress.org/support/users/ythibodeau/)
 * (@ythibodeau)
 * [20 years, 3 months ago](https://wordpress.org/support/topic/different-backgrounds-for-comments/)
 * How can I get all odds comments to have a grey background, and all even ones 
   to have a white one?

Viewing 15 replies - 1 through 15 (of 18 total)

1 [2](https://wordpress.org/support/topic/different-backgrounds-for-comments/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/different-backgrounds-for-comments/page/2/?output_format=md)

 *  [moshu](https://wordpress.org/support/users/moshu/)
 * (@moshu)
 * [20 years, 3 months ago](https://wordpress.org/support/topic/different-backgrounds-for-comments/#post-347235)
 * You can check how it is done in the default theme. See the comments.php and the
   stylesheet.
 *  Thread Starter [ythibodeau](https://wordpress.org/support/users/ythibodeau/)
 * (@ythibodeau)
 * [20 years, 3 months ago](https://wordpress.org/support/topic/different-backgrounds-for-comments/#post-347335)
 * That’s the only thing I can see???
 *  `<?php /* Changes every other comment to a different class */ 
    if ('alt' ==
   $oddcomment) $oddcomment = ''; else $oddcomment = 'alt'; ?>
 *  Thread Starter [ythibodeau](https://wordpress.org/support/users/ythibodeau/)
 * (@ythibodeau)
 * [20 years, 3 months ago](https://wordpress.org/support/topic/different-backgrounds-for-comments/#post-347530)
 * Anyone?
 *  [viper007bond](https://wordpress.org/support/users/viper007bond/)
 * (@viper007bond)
 * [20 years, 3 months ago](https://wordpress.org/support/topic/different-backgrounds-for-comments/#post-347531)
 * What about it? You have the code right there…
 * It gives comment #1 CSS class A and then if the previous comment was given CSS
   class A, then it gives comment #2 CSS class B, then A, etc.
 * Or are you just not understanding what to do with that code?
 *  [spencerp](https://wordpress.org/support/users/spencerp/)
 * (@spencerp)
 * [20 years, 3 months ago](https://wordpress.org/support/topic/different-backgrounds-for-comments/#post-347532)
 * This “might” help…please note I said “might”…
    [http://wordpress.org/support/topic/24539?replies=24](http://wordpress.org/support/topic/24539?replies=24)
   [http://wordpress.org/support/topic/12668?replies=4#post-75051](http://wordpress.org/support/topic/12668?replies=4#post-75051)
 * spencerp
 *  Thread Starter [ythibodeau](https://wordpress.org/support/users/ythibodeau/)
 * (@ythibodeau)
 * [20 years, 3 months ago](https://wordpress.org/support/topic/different-backgrounds-for-comments/#post-347533)
 * I need to nknow where to insert the class names…
 *  [moshu](https://wordpress.org/support/users/moshu/)
 * (@moshu)
 * [20 years, 3 months ago](https://wordpress.org/support/topic/different-backgrounds-for-comments/#post-347534)
 * You don’t have to insert anything – just have that code in your comments.php.
   WP does the rest.
    The only thing you have to do: define the .alt class in your
   stylesheet.
 *  Thread Starter [ythibodeau](https://wordpress.org/support/users/ythibodeau/)
 * (@ythibodeau)
 * [20 years, 3 months ago](https://wordpress.org/support/topic/different-backgrounds-for-comments/#post-347537)
 * Any example of .alt class for me?
 *  [moshu](https://wordpress.org/support/users/moshu/)
 * (@moshu)
 * [20 years, 3 months ago](https://wordpress.org/support/topic/different-backgrounds-for-comments/#post-347539)
 * Yes, in the stylesheet of the default theme.
 *  [spencerp](https://wordpress.org/support/users/spencerp/)
 * (@spencerp)
 * [20 years, 3 months ago](https://wordpress.org/support/topic/different-backgrounds-for-comments/#post-347540)
 * Something like this: (Example ONLY!)
 * `.commentlist li.alt {
    background: #f0f; }
 * Got that from here:
    [http://wordpress.org/support/topic/24539?replies=24#post-138514](http://wordpress.org/support/topic/24539?replies=24#post-138514)
 * spencerp
 *  Thread Starter [ythibodeau](https://wordpress.org/support/users/ythibodeau/)
 * (@ythibodeau)
 * [20 years, 3 months ago](https://wordpress.org/support/topic/different-backgrounds-for-comments/#post-347562)
 * I only get the header of the comment to be different?
    I want the entire comment…
 * See below:
    [http://www.coldplayfansite.com/wordpress/?p=3](http://www.coldplayfansite.com/wordpress/?p=3)
 *  [spencerp](https://wordpress.org/support/users/spencerp/)
 * (@spencerp)
 * [20 years, 3 months ago](https://wordpress.org/support/topic/different-backgrounds-for-comments/#post-347563)
 * Will any of these might help ya then:
 * [http://www.scriptygoddess.com/archives/2004/06/21/comment-highlighting-based-on-author/](http://www.scriptygoddess.com/archives/2004/06/21/comment-highlighting-based-on-author/)
   
   or [http://www.dailydoodles.dk/archives/2004/08/03/plugin-my-comments-for-wordpress/](http://www.dailydoodles.dk/archives/2004/08/03/plugin-my-comments-for-wordpress/)
   or [http://mookitty.co.uk/devblog/archives/2004/07/28/comment-backgrounds-hack/](http://mookitty.co.uk/devblog/archives/2004/07/28/comment-backgrounds-hack/)
 * Got that from here at this thread:
    [http://wordpress.org/support/topic/12668?replies=4#post-75051](http://wordpress.org/support/topic/12668?replies=4#post-75051)
 * spencerp
 *  [silkjaer](https://wordpress.org/support/users/silkjaer/)
 * (@silkjaer)
 * [20 years, 3 months ago](https://wordpress.org/support/topic/different-backgrounds-for-comments/#post-347564)
 * or
 * [http://theundersigned.net/2006/03/wordpress-change-look-of-every-second-post/](http://theundersigned.net/2006/03/wordpress-change-look-of-every-second-post/)
 *  [spencerp](https://wordpress.org/support/users/spencerp/)
 * (@spencerp)
 * [20 years, 3 months ago](https://wordpress.org/support/topic/different-backgrounds-for-comments/#post-347565)
 * Hahaha…Silkjaer, anything….and I mean anything to get this solved! LOL! =)
 * [Goes back to working on a crappy theme=>…
 * spencerp
 *  Thread Starter [ythibodeau](https://wordpress.org/support/users/ythibodeau/)
 * (@ythibodeau)
 * [20 years, 3 months ago](https://wordpress.org/support/topic/different-backgrounds-for-comments/#post-347590)
 * There is obviously something wrong…
 * See below:
    [http://www.coldplayfansite.com/wordpress/?p=3](http://www.coldplayfansite.com/wordpress/?p=3)
 * Code in comments.php is:
 *  `<div class="commentlist">`
 *  <?php foreach ($comments as $comment) : ?>
 *  <p class="<?php echo $oddcomment; ?>" id="comment-<?php comment_ID() ?>">
    <
   strong><?php comment_author() ?></strong>'s comment: <?php if ($comment->comment_approved
   == '0') : ?> <em>Your comment is awaiting moderation.</em> <?php endif; ?>
 *  <small><?php comment_date('F jS, Y') ?> at <?php comment_time() ?> <?php edit_comment_link('
   Edit comment','',''); ?></small>
 *  <?php comment_text() ?>
 *  <?php /* Changes every other comment to a different class */ 
    if ('alt' == 
   $oddcomment) $oddcomment = ''; else $oddcomment = 'alt'; ?>
 *  <?php endforeach; /* end for each comment */ ?>
 *  </div>
 * And css is:
 * `.commentlist p.alt {
    background: #eeeeee; }
 * But only headers get the .alt and not the entire comment, which should be included
   since it’s between the 2 `<p>`

Viewing 15 replies - 1 through 15 (of 18 total)

1 [2](https://wordpress.org/support/topic/different-backgrounds-for-comments/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/different-backgrounds-for-comments/page/2/?output_format=md)

The topic ‘Different backgrounds for comments…’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 18 replies
 * 5 participants
 * Last reply from: [ythibodeau](https://wordpress.org/support/users/ythibodeau/)
 * Last activity: [20 years, 3 months ago](https://wordpress.org/support/topic/different-backgrounds-for-comments/page/2/#post-347646)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
