Home / comment / Alternate comment colors
  • How to Alternate comment colors

    no thumbnail sorry: Alternate comment colors

    Adding this code to your comments will allow you to alternate colors in your comments.

    ( click code to copy )

    wordpress snippet : PHP

    <>
    <?php if ( $comments ) : ?>:
    <ul>
    <?php
              $i = 0;
              foreach ($comments as $comment) :
              $i++;
    ?>
    <li id="comment-<?php comment_ID() ?>"<?php if($i&1) { echo 'class="odd"';} else {echo 'class="even"';} ?>>
    
    ( click code to copy )

    wordpress snippet : CSS

    <>
    .odd  {background: #e5e5e5; }
    .even {background: #ccc; }
    

    ( WordPress codex functions, hooks, in this snippet. )

    comment_ID,