Issue with PHP loop not displaying all elements

The following code snippet for a wordpress page for some reason is not displaying all of the elements in the this loop. It is only displaying one of the three that are actually returned for $latest_comment. When I console out $latest_comment I get three Obj, all of which I want to run through and display.

Everything looks fine to me but I’m looking with tired eyes. Any help is appreciated. It seems it must be in the if statement following the $latest_comment assignment.

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

Related posts

1 comment

Comments are closed.