admin管理员组文章数量:1306835
I have author pages for each author and I want to see all of their comments (or all of their recent comments) if I click on their nickname. How can I do this? I tried the beneath code, but that does not show the unique comments per user... It just outputs all recent comments from everyone combined, but I don't want that.
<?php
$author_email = get_the_author_meta( 'user_email' );
$args = array(
'author_email' => $author_email,
'number' => '10'
);
$comments = get_comments($args);
foreach($comments as $comment) :
echo('<li class="comment">' . $somment->comment_content),'<h5><a href='.get_permalink($comment->comment_post_ID).'>', get_the_title($comment->comment_post_ID), '</a></h5>', '<time><em>' . $comment->get_comment_date . '</em></time>', '</li>';
endforeach;
?>
</ul></div>
I have author pages for each author and I want to see all of their comments (or all of their recent comments) if I click on their nickname. How can I do this? I tried the beneath code, but that does not show the unique comments per user... It just outputs all recent comments from everyone combined, but I don't want that.
<?php
$author_email = get_the_author_meta( 'user_email' );
$args = array(
'author_email' => $author_email,
'number' => '10'
);
$comments = get_comments($args);
foreach($comments as $comment) :
echo('<li class="comment">' . $somment->comment_content),'<h5><a href='.get_permalink($comment->comment_post_ID).'>', get_the_title($comment->comment_post_ID), '</a></h5>', '<time><em>' . $comment->get_comment_date . '</em></time>', '</li>';
endforeach;
?>
</ul></div>
Share
Improve this question
asked May 15, 2013 at 7:24
user1627363user1627363
1724 silver badges21 bronze badges
2 Answers
Reset to default 8your problem is using author_email
, you need user_id
:
i just use similar script.
<?php
$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";}
?>
Check This Show Comments by User ID in WordPress
本文标签: Display all comments or recent comments per user on author page
版权声明:本文标题:Display all comments or recent comments per user on author page 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741816874a2399129.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论