Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/267.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php WP\u Comment\u查询中的Comment对象为空_Php_Wordpress Theming_Wordpress - Fatal编程技术网

Php WP\u Comment\u查询中的Comment对象为空

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代码:

<?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>