酷秀博客
首页/typecho统计父级评论下面的“子级评论”有多少条?教程

typecho统计父级评论下面的“子级评论”有多少条?

admin的头像admin7个月前教程168热度

最近用独立页面编写的一个朋友圈模板,基于评论功能实现。
为了实现显示父级评论下面有多少条子级评论,让页面看起更加舒适。
实现函数代码

function parent($coid) {
$db = Typecho_Db::get();
$parent = $db->select('table.comments.parent')->from('table.comments')->where('parent = ?', $coid);
$parent=$db->fetchAll($parent);
return count($parent);
}

使用代码,一般添加到comments.php文件中(需要自定义评论才能使用)。

<?php echo parent($comments->coid);?>

签名: 最忠诚的BUG开发者来自: 重庆市. Chrome浏览器
文章目录