List recent comments from a specified array of users
-
Hi, I am trying to display a list of recent comments from several specific users (in my case user ids 14,56,58,200) who form a team. On their team page I simply want to list their recent comments.
On each team members individual page I run a query that displays that one team members comments, using this code:
<?php $args = array( 'user_id' => 200, // TEAM MEMBER 'number' => 3, // how many comments to retrieve 'status' => 'approve' ); $comments = get_comments( $args ); if ( $comments ) { $output.= "<ul class=lastcomments>\n"; foreach ( $comments as $c ) { $output.= '<li><p>'; $output.= get_comment_excerpt($c->comment_ID); $output.= '</br><span>Posted in: <a href="'.get_comment_link( $c->comment_ID ).'">'; $output.= get_the_title($c->comment_post_ID); $output.= '</a>'; $output.= ' on '. mysql2date('m/d/Y', $c->comment_date, $translate); $output.= "</span></p></li>\n"; } $output.= '</ul>'; echo $output; } else { echo "No comments made";}?>
The formatting needs to be the same, just with 5 specified users instead of 1.
But all attempts to display multiple users comments (using an array for user_id for example) have failed so far. It seems strange that it would be so complicated to pull multiple user comments, considering what can be done with queries in WordPress.
But after 3 hours of tinkering and searching I have hit a coding wall. Any help would be greatly appreciated!
- The topic ‘List recent comments from a specified array of users’ is closed to new replies.