Get last comments from author
-
Hi, I would like to show the 5 last comments from the author of the post, on the post page. I tried many codes but I can’t get the comments…
Here is the code so far:
<?php $number=5; $comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_approved = '1' and comment_author_email='$curauth->user_email' ORDER BY comment_date_gmt DESC LIMIT $number"); ?> <?php if ( $comments ) : foreach ( (array) $comments as $comment) : echo '<a href="'. get_comment_link($comment->comment_ID) . '">' . get_the_title($comment->comment_post_ID) . '') . ''; endforeach; else: ?> <?php _e('No comments from the author.'); ?> <?php endif; ?>Thanks for your help! 🙂
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
The topic ‘Get last comments from author’ is closed to new replies.