我试图将php查询解析为html,但在html页面上它显示了数组。
我的查询如下:$comments = get_comments( array('post_id' => $post->ID, 'status' => 'approve') );
我尝试使用以下命令在html页面上打印它:$html .= $comments;
正如你从examples看到的那样。
正如Tom J Nowell评论的那样,你需要遍历每个评论并将评论附加到$ html。
$args = array(
'status' => 'approve',
'post_id' => $post->ID,
);
$comments = get_comments( $args );
foreach ( $comments as $comment ) :
$html .= $comment->comment_author . '<br />' . $comment->comment_content . '<br />';
endforeach;