I found this code online but I want to make some edit to the code to display comments of the author. Current the format of the output is " {{Post Tile}} - {{Post Date}}.
How should I tweak the code to dislay the comment content as well such that the format is as follows: {{comment content}} - {{post title}} - {{post date}}
function display_authors_comments() {
$args = array(
'user_id' => get_the_author_meta('ID'),
'number' => 10, // how many comments to retrieve
'status' => 'approve'
);
$comments = get_comments( $args );
if ( $comments )
{
$output.= "<ul>\n";
foreach ( $comments as $c )
{
$output.= '<li>';
$output.= '<a href="'.get_comment_link( $c->comment_ID ).'">';
$output.= get_the_title($c->comment_post_ID);
$output.= '</a>, Posted on: '. mysql2date('m/d/Y', $c->comment_date, $translate);
$output.= "</li>\n";
}
$output.= '</ul>';
echo $output;
} else { echo "No comments made";}
}
Add_shortcode( 'displayauthoscomments', 'display_authors_comments' );
Thank you very much
guys!
Comments
Post a Comment