我有一个关于帖子中评论数字的问题。。。现在,我可以在循环外的帖子中输出评论总数。这很酷,但我想show the comment number/amount of a post PER DAY. 所以让我们假设我有一篇帖子,人们今天评论了10次。。。然后,我想在帖子标题后显示“10条评论”。。。如果一天过去了,第二天只有一个人发表评论,我希望它在帖子标题后输出“1条评论”。。。
这是否可能,如果可能,如何实现?
我想使用以下函数输出“每篇文章之后的每篇文章今天的评论”:
function wowPosts($num) {
global $wpdb;
$posts = $wpdb->get_results("SELECT comment_count, ID, post_title FROM $wpdb->posts ORDER BY comment_count DESC LIMIT 0 , $num");
foreach ($posts as $post) {
setup_postdata($post);
$id = $post->ID;
$title = $post->post_title;
$count = $post->comment_count;
$comment_count = get_comment_count($post->ID);
$all_comments = get_comment_count( array ( \'post_id\' => get_the_ID() ) );
if ($count != 0) {
$popular .= \'<li>\';
$popular .= \'<a href="\' . get_permalink($id) . \'" title="\' . $title . \'">\' . $title . \'</a> \'. count( $all_comments ) . \' \';
$popular .= \'</li>\';
}
}
return $popular;
}