WordPress获取评论用户的信息
发布时间:2020-12-14 14:43:39  所属栏目:wordpress  来源:网络整理 
            导读:在上一篇文章中,我们输出了评论用户头像列表,那么,我们能不能再输出一些评论者的信息呢?比如:某读者的最后评论时间,总的评论文章,最后评论内容,在本站总的评论数等,通过下面的代码您可以轻松实现: 通过WordPress我们可以轻松获取文章总的评论数,
                
                
                
            | 
                         在上一篇文章中,我们输出了评论用户头像列表,那么,我们能不能再输出一些评论者的信息呢?比如:某读者的最后评论时间,总的评论文章,最后评论内容,在本站总的评论数等,通过下面的代码您可以轻松实现: 
 
                    通过WordPress我们可以轻松获取文章总的评论数,同时在文章中通过列表展示出来,最近在制作评论模板的时候我就在想,能… 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开发教程:去除后台标题中的“—— WordPress”
 - WordPress快速添加友情链接功能的方法
 - Coming soon and Maintenance mode – WordPress正在建
 - WordPress中函数get_term_link的参数设置问题
 - 代码实现WordPress自定义默认头像
 - 将WordPress文章别名设置为文章ID、英文、拼音完全教程
 - 在WordPress文章后添加作者简介的方法
 - 提取WordPress中的多语言系统
 - 初识WordPress(功能非常强大的全世界主流的博客系统)
 - WordPress图片压缩优化插件 – EWWW Image Optimizer
 
