Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/13.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循环未显示所有元素的问题_Php_Wordpress - Fatal编程技术网

PHP循环未显示所有元素的问题

PHP循环未显示所有元素的问题,php,wordpress,Php,Wordpress,由于某些原因,wordpress页面的以下代码段未显示此循环中的所有元素。它只显示了以$latest_comment返回的三个注释中的一个。当我控制台输出$latest_注释时,我得到了三个Obj,所有这些我都想运行并显示 我觉得一切都很好,但我的眼睛很疲惫。感谢您的帮助。似乎它一定在$latest_comment赋值后的if语句中 <?php $num_comment=get_comments_number(); if($num_c

由于某些原因,wordpress页面的以下代码段未显示此循环中的所有元素。它只显示了以$latest_comment返回的三个注释中的一个。当我控制台输出$latest_注释时,我得到了三个Obj,所有这些我都想运行并显示

我觉得一切都很好,但我的眼睛很疲惫。感谢您的帮助。似乎它一定在$latest_comment赋值后的if语句中

<?php $num_comment=get_comments_number();
                            if($num_comment > 0){ ?>
                            <div class="item-title">
                            <?php $args = array(
                                'number' => 10000,
                                'post_id' => $post->ID,
                                'status' => 'approve'
                            );?>
                            <?php $latest_comment = get_comments($args);
                            //returns 3 Obj which is correct


                            if( $latest_comment ) foreach( $latest_comment as $comment ) { 

                                $vote = get_comment_meta( $comment->comment_ID, 'age1', true );
                                //var_dump($vote);
                                if($vote=="on"){
                                ?>

                            <div class="item-b-l">
                                .....html stuff here....
                            </div>

                            <?php  break; } ?>
                            <?php } ?>


                        </div>

                       <?php } ?>

…这里是html内容。。。。

删除
您的代码

谢谢,…奇怪的是,删除该行不会显示任何内容。目前,该行只显示最新的对象。啊,所以我只是从代码中删除了
break
,仍然得到与我保留
break
相同的结果。