WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Query author's comments (2 posts)

  1. jkmuller
    Member
    Posted 6 years ago #

    Is there any way to display the author/user's last few comments on the author template, or would it require a custom query?

  2. jkmuller
    Member
    Posted 6 years ago #

    Solved. My solution was to add this section of code:

    <?php $querystr = "
    SELECT *
    FROM $wpdb->comments
    WHERE $wpdb->comments.comment_author = '".$curauth->user_login."'
    AND comment_approved = '1'
    ORDER BY comment_date DESC";
    $results = $wpdb->get_results($querystr, OBJECT);
    
    $i=0;
    foreach ($results as $comment) :
    ?>

    Then I added the necessary HTML interspersed with variables such as <?php echo $results[$i]->comment_content; ?>
    I ended with `<?php
    $i++;
    endforeach;
    ?>`

Topic Closed

This topic has been closed to new replies.

About this Topic