我的观点是:显示帖子最后的评论者姓名和评论日期d F H:i在一起。有什么建议吗?
我想你想要的是:
$defaults = array(
\'post_id\' => $post->ID,
\'number\' => \'1\',
\'orderby\' => \'comment_date_gmt \', // default value; not really necessary
\'order\' => \'DESC\',
\'status\' => \'approved\',
);
你不需要跑
get_comments()
两次
$defaults = array(
\'post_id\' => 120,
\'number\' => \'1\',
\'orderby\' => \'comment_date_gmt \', // default value; not really necessary
\'order\' => \'DESC\',
\'status\' => \'approved\',
);
$comments = get_comments($defaults);
if (!empty($comments[0])) {
$comments = $comments[0];
comment_author($comments->comment_ID);
comment_date(\'d F H:i\', $comments->comment_ID);
}