• Resolved hellodrifter

    (@hellodrifter)


    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

    (@hellodrifter)

    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.