Title: Conditional Statements for Comments Loop/Loop Structure
Last modified: August 20, 2016

---

# Conditional Statements for Comments Loop/Loop Structure

 *  Resolved [hellodrifter](https://wordpress.org/support/users/hellodrifter/)
 * (@hellodrifter)
 * [14 years, 11 months ago](https://wordpress.org/support/topic/conditional-statements-for-comments-looploop-structure/)
 * I am using the comment_form and wp_list_comments functions as the guts of my 
   comments template. What I want to know is what the basic bones structure of my
   comments loop will look like. Also, do I fill the comments loop with template
   tags to structure my comments, like with the index loop? The themes I’ve looked
   at leave me a bit confused.
 * Maybe a visual example will help. So if my index loop conditional statements 
   look kinda like this.
 *     ```
       <?php if (have_posts()) : ?>
   
       <?php while (have_posts()) : the_post(); ?>
   
       <?php endwhile; ?>
   
       <?php else : ?>	
   
       <?php endif; ?>
       ```
   
 * What is the basic equivalent for the comments loop? Should I be placing coding
   like this in between comment loop conditional statements to form my loop?
 *     ```
       <p class="reply_author"><?php comment_author(); ?></p>
       <p class="reply_time"> <?php comment_date(F jS, Y g:i a); ?></p>
       <p class="reply_body"><?php comment_text(); ?></p>
       ```
   
 * Thx so much for any help. 🙂

Viewing 1 replies (of 1 total)

 *  Thread Starter [hellodrifter](https://wordpress.org/support/users/hellodrifter/)
 * (@hellodrifter)
 * [14 years, 11 months ago](https://wordpress.org/support/topic/conditional-statements-for-comments-looploop-structure/#post-2154532)
 * Okay, never-mind my ramblings. I’ve found out that what I am referring to (using
   a foreach loop for outputting comments) is the pre-2.7 way of making a comments
   template, so it’s obsolete. I’ll leave an explanation in case anyone else has
   the same question.
 * What I need is not a traditional comments loop, but to edit the way comments 
   are output by `<?php wp_list_comments(); ?>`.
 * If you want to drastically alter the output structure of your comments like me,
   this is achieved through use of the callback feature of list comments.
 * So just throw this line of code down `<?php wp_list_comments('callback=custom_comment');?
   >` in comments.php and then, in your functions.php template, define your own 
   custom function, in this case, named ‘custom_comment’. Your custom function will
   control the way comments are structured. There are examples in the codex and 
   elsewhere so I’ll leave you to search. Goodluck!

Viewing 1 replies (of 1 total)

The topic ‘Conditional Statements for Comments Loop/Loop Structure’ is closed to
new replies.

## Tags

 * [php](https://wordpress.org/support/topic-tag/php/)

 * 1 reply
 * 1 participant
 * Last reply from: [hellodrifter](https://wordpress.org/support/users/hellodrifter/)
 * Last activity: [14 years, 11 months ago](https://wordpress.org/support/topic/conditional-statements-for-comments-looploop-structure/#post-2154532)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
