ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
~~~ /** * 获取文章的评论人数 *$postid:文章id *$which:返回类型(0或1)为0时返回评论人数,为1时返回评论条数 */ function count_comments($postid=0,$which=0) { $comments = get_comments('status=approve&type=comment&post_id='.$postid); //获取文章的所有评论 if ($comments) { $i=0; $j=0; $commentusers=array(); foreach ($comments as $comment) { ++$i; if ($i==1) { $commentusers[] = $comment->comment_author_email; ++$j; } if ( !in_array($comment->comment_author_email, $commentusers) ) { $commentusers[] = $comment->comment_author_email; ++$j; } } $output = array($j,$i); $which = ($which == 0) ? 0 : 1; return $output[$which]; //返回评论人数 } return 0; //没有评论返回0 } ~~~