Php WP\u Comment\u查询中的Comment对象为空
以下是我的PHP代码:Php WP\u Comment\u查询中的Comment对象为空,php,wordpress-theming,wordpress,Php,Wordpress Theming,Wordpress,以下是我的PHP代码: <?php $comments_query = new WP_Comment_Query(); $comments = $comments_query->query( array( 'number' => 5 ) ); if ($comments) { foreach ( $comments as $comment ) { ?> <div clas
<?php
$comments_query = new WP_Comment_Query();
$comments = $comments_query->query( array( 'number' => 5 ) );
if ($comments)
{
foreach ( $comments as $comment ) {
?>
<div class="comment" id="comment-<?php $comment->comment_ID ?>">
<div class="avatar">
<?php get_avatar( $comment->comment_author_email, 48 ); ?>
</div>
<div class="text>
<a class="author" href="<?php get_permalink( $comment->comment_post_ID ) . '#comment-' . $comment->comment_ID; ?>">
<?php get_comment_author( $comment->comment_ID ) ?>
</a>
<?php strip_tags( substr( apply_filters( 'get_comment_text', $comment->comment_content ), 0, 80 ) ) . '...'; ?></p>
</div>
</div>
<?php
}
} else {
echo 'none.';
}
?>
明白了,这很愚蠢,但即使我调用了这些方法,我也没有回显结果
<div class="comment" id="comment-">
<div class="avatar">
</div>
<div class="text>
<a class=" author"="" href="">
<p></p>
</div>
</div>