Title: Alternating Comments
Last modified: August 19, 2016

---

# Alternating Comments

 *  [leo22](https://wordpress.org/support/users/leo22/)
 * (@leo22)
 * [18 years, 1 month ago](https://wordpress.org/support/topic/alternating-comments/)
 * Hello,
    Im having some problems with my alternating comments. From what I understand,
   the only class you use for that is “alt”, but my problem is that I have more 
   than one class for the odd comments.
 * These are my even comments in plain HTML:
 *     ```
       <div class="comment_top"></div><div class="comment_middle">
       <div class="comment_num">1.</div>
       <div class="comment_text">
   
       COMMENT TEXTTT
   
       </div>
       </div><div class="comment_bottom">Posted by <a href="#">Elena</a> on April 15, 2008 @ 4:39 pm</div>
       ```
   
 * And these are my odd comments in plain HTML
 *     ```
       <div class="comment_top2"></div><div class="comment_middle2">
       <div class="comment_num2">2.</div>
       <div class="comment_text2">
   
       COMMENT TEXTTT
   
       </div>
       </div><div class="comment_bottom2">Posted by <a href="#">Elena</a> on April 15, 2008 @ 4:39 pm</div>
       ```
   
 * How can I have alternating comments like this?

Viewing 1 replies (of 1 total)

 *  Thread Starter [leo22](https://wordpress.org/support/users/leo22/)
 * (@leo22)
 * [18 years, 1 month ago](https://wordpress.org/support/topic/alternating-comments/#post-745581)
 * by the way, this is the code for my comments.php page:
 *     ```
       <?php // Do not delete these lines
       	if ('comments.php' == basename($_SERVER['SCRIPT_FILENAME']))
       		die ('Please do not load this page directly. Thanks!');
   
               if (!empty($post->post_password)) { // if there's a password
                   if ($_COOKIE['wp-postpass_' . COOKIEHASH] != $post->post_password) {  // and it doesn't match the cookie
       				?>
   
       This post is password protected. Enter the password to view comments.
   
       				<?php
       				return;
                   }
               }
       		/* This variable is for alternating comment background */
       		$oddcomment = 'comment_bottom';
       ?>
   
       <!-- You can start editing here. -->
   
       <?php if ($comments) : ?>
   
       <ol>
       	<?php $commentcounter = 0; ?>
       	<?php foreach ($comments as $comment) : ?>
       		<?php $commentcounter++; ?>
   
       <div class="comment_top"></div><div class="comment_middle">
       <div class="comment_num"><li id="comment-<?php comment_ID() ?>">
   
       <?php echo $commentcounter; ?>.
   
       </div>
   
       <div class="comment_text">
   
       <?php if ($comment->comment_approved == '0') : ?>
       <em>Your comment is awaiting moderation.</em>
       <?php endif; ?>
   
       <?php comment_text() ?>
       </li>
   
       </div>
       </div><div class="comment_bottom">Posted by <a href="#"><?php comment_author_link() ?></a> on <a href="#comment-<?php comment_ID() ?>" title="" class="datelink"><?php comment_date('M j, Y') ?> @ <?php comment_time() ?></a> <?php edit_comment_link('(Edit)','',''); ?></div>
   
       	<?php /* Changes every other comment to a different class */
       		if ('comment_bottom' == $oddcomment) $oddcomment = '';
       		else $oddcomment = 'comment_bottom';
       	?>
   
       	<?php endforeach; /* end for each comment */ ?>
   
       </ol>
   
        <?php else : // this is displayed if there are no comments so far ?>
   
         <?php if ('open' == $post->comment_status) : ?>
       		<!-- If comments are open, but there are no comments. -->
   
       	 <?php else : // comments are closed ?>
       		<!-- If comments are closed. -->
       		<p class="nocomments">Comments are closed.</p>
   
       	<?php endif; ?>
       <?php endif; ?>
   
       <?php if ('open' == $post->comment_status) : ?>
   
       <?php if ( get_option('comment_registration') && !$user_ID ) : ?>
       <br />You must be <a href="<?php echo get_option('siteurl'); ?>/wp-login.php?redirect_to=<?php the_permalink(); ?>" class="datelink">logged in</a> to post a comment.
       <?php else : ?>
   
       <form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform">
   
       <?php if ( $user_ID ) : ?>
   
       <br />Logged in as <a class="datelink" href="<?php echo get_option('siteurl'); ?>/wp-admin/profile.php"><?php echo $user_identity; ?></a>. <a href="<?php echo get_option('siteurl'); ?>/wp-login.php?action=logout" title="Log out of this account" class="datelink">Logout &raquo;</a><br />
   
       <?php else : ?>
   
       <br /><strong>Name</strong>: <?php if ($req) echo "*"; ?><br />
       <input type="text" name="author" id="author" value="<?php echo $comment_author; ?>" size="97%" tabindex="1" />
   
       <br /><strong>E-Mail</strong>: <?php if ($req) echo "*"; ?> (not displayed)<br />
       <input type="text" name="email" id="email" value="<?php echo $comment_author_email; ?>" size="97%" tabindex="2" />
   
       <br /><strong>Website</strong>:<br />
       <input value="http://elena.esaudrae.net/" type="text" name="url" id="url" value="<?php echo $comment_author_url; ?>" size="97%" tabindex="3" />
   
       <?php endif; ?>
   
       <br /><strong>Comment</strong>:<br />
       <textarea name="comment" id="comment" cols="60%" rows="6" tabindex="4"></textarea>
   
       <br /><input name="submit" type="submit" id="submit" tabindex="5" value="Submit Comment" />
       <input type="hidden" name="comment_post_ID" value="<?php echo $id; ?>" />
        <input type="reset" name="reset" value="Reset Comment">
   
       <?php do_action('comment_form', $post->ID); ?>
   
       </form>
   
       <?php endif; // If registration required and not logged in ?>
   
       <?php endif; // if you delete this the sky will fall on your head ?>
       ```
   

Viewing 1 replies (of 1 total)

The topic ‘Alternating Comments’ is closed to new replies.

 * 1 reply
 * 1 participant
 * Last reply from: [leo22](https://wordpress.org/support/users/leo22/)
 * Last activity: [18 years, 1 month ago](https://wordpress.org/support/topic/alternating-comments/#post-745581)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
