在上一篇文章中,我们输出了评论用户头像列表,那么,我们能不能再输出一些评论者的信息呢?比如:某读者的最后评论时间,总的评论文章,最后评论内容,在本站总的评论数等,通过下面的代码您可以轻松实现:
通过WordPress我们可以轻松获取文章总的评论数,同时在文章中通过列表展示出来,最近在制作评论模板的时候我就在想,能…
//获取指定用户评论总数目
function get_author_comment_count($comment_author_email){
global $wpdb;
$comment_count = count($wpdb->get_results(
"SELECT comment_ID as author_count FROM $wpdb->comments WHERE comment_author_email = '$comment_author_email' "));
return $comment_count;
}
//获取指定用户最后评论内容
function author_last_comment_content($comment_author_emails){
$args = array(
'author_email' =>$comment_author_emails,
'number' => '1'
);
$comments = get_comments($args);
foreach($comments as $comment) :
return $comment->comment_content;
endforeach;
}
//获取指定用户最后时间
function author_last_comment_time($comment_author_emails){
$args = array(
'author_email' =>$comment_author_emails,
'number' => '1'
);
$comments = get_comments($args);
foreach($comments as $comment) :
return $comment->comment_date_gmt;
endforeach;
}
具体的调用方法大家自己研究吧!
感谢您的打赏,我们会更加努力的更新站点!
本文链接:WordPress获取评论用户的信息
转载声明:本站文章若无特别说明,皆为原创,转载请注明来源:刘荣焕,谢谢!
罐 4年前 (2018-09-14)
广东省的
B站 4年前 (2018-07-24)
学习了