Title: Comment Styling with 3 or more styles (using array)?
Last modified: August 21, 2016

---

# Comment Styling with 3 or more styles (using array)?

 *  [Starryskeyes](https://wordpress.org/support/users/starryskeyes/)
 * (@starryskeyes)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/comment-styling-with-3-or-more-styles-using-array/)
 * Hello,
 * I’m using theme Twenty Ten. I have already created the CSS for the styling and
   it is good. I have seen it done once with styles that were over 3 different types,
   but can not find that blog again. I am trying to create a loop/array of comment
   styles.
 * Because it is set to odd comments it can only alternate between two. I need to
   find some other method. Any ideas on how to proceed.
 * Here is the current alternating code below.
 * —————
 *     ```
       <?php if ($comments) : ?>
       	<h3 id="comments"><?php comments_number('No Responses', 'One Response', '% Responses' );?> to “<?php the_title(); ?>”</h3> 
   
       	<ol class="commentlist">
   
       	<?php foreach ($comments as $comment) : ?>
               <div class="<?=($i%2)?"img2comment":"img1comment";$i++;?>">
   
               <?php
               $isByAuthor = false;
               if($comment->comment_author_email ==
               'email1') {
               $isByAuthor = true;
               }
               ?>
   
               <?php
               $isByauthor2 = false;
               if($comment->comment_author_email ==
               'email2') {
               $isByauthor2 = true;
               }
               ?>
       ```
   
 * ————————–
    you can see it here: [http://artandillumination.com/2012/black-swamp-arts-festival-gearing-up-for-20th/](http://artandillumination.com/2012/black-swamp-arts-festival-gearing-up-for-20th/)
 * From there I would like to find a way to stop the loop/array if made by specific
   author.
 * Thanks for your help!!!!

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

 *  Thread Starter [Starryskeyes](https://wordpress.org/support/users/starryskeyes/)
 * (@starryskeyes)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/comment-styling-with-3-or-more-styles-using-array/#post-4674321)
 * I was thinking something along these lines:
 *     ```
       <?php
         $i = 0; ?>
         foreach ($comments as $comment) :
         $i++;
       ?>
       <li id="comment-<?php comment_ID() ?>"
         <?php switch ($i % 6) {
           case 0:
               echo 'class="image1comment"';
               break;
           case 1:
               echo 'class="image2comment"';
               break;
           case 2:
               echo 'class="image3comment"';
               break;
         }
         ?>
       ```
   
 * It’s not working though and I’m not sure what I am missing.
 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/comment-styling-with-3-or-more-styles-using-array/#post-4674338)
 * try to use 3 in this line:
 *     ```
       <?php switch ($i % 3) {
       ```
   
 * > It’s not working though
 * what is the result?

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

The topic ‘Comment Styling with 3 or more styles (using array)?’ is closed to new
replies.

## Tags

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

 * 2 replies
 * 2 participants
 * Last reply from: [Michael](https://wordpress.org/support/users/alchymyth/)
 * Last activity: [12 years, 2 months ago](https://wordpress.org/support/topic/comment-styling-with-3-or-more-styles-using-array/#post-4674338)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
