• Resolved zoekatz

    (@zoekatz)


    I am trying to go through the comments loop inside of the post Loop and return a list of all the authors who have commented.

    I put the following into the Loop (which doesn’t work – my Loop is working and returning other information) –

    <?php foreach ($comments as $comment) : ?>
    <?php global $comment; ?>www<?php echo $comment_author; ?>
    <?php endforeach; ?>

    What I’m doing is writing xml from the php to go into a flash interface for my blog. I need to know all the names of the people who have commented (everyone is logged in) or more specifically if the user that is logged in currently has commented on the post. This information needs to be in a string on this page and inserted into the XML that I’m creating with the Loop that goes through all of the posts.

    Thanks for any advice on this.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Problem here is the $comments object does not exist until the comments template is loaded. You’ll have to query the database to get at them:

    <?php
    $comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = '$post->ID' AND comment_approved = '1' ORDER BY comment_date");
    foreach( $comments as $comment ) :
    ?>

    Thread Starter zoekatz

    (@zoekatz)

    Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘template – get comment author information in the Loop’ is closed to new replies.