Bootstrap Wordpress循环功能

I am trying to get my loop to repeat print 6 images and then end the ul and print another 6 images and repeat.

But it keeps printing them all in the same ul which is causing the page to break.

Any way to get the loop to work properly and print it out correctly?

A link to the page is http://nerdclients.com/dev2/teena/all-pages/

Thanks in advance!

<ul class="col-lg-12">
        <?php
        $i=0;
        if ( get_query_var('paged') ) {
            $paged = get_query_var('paged');
        } else if ( get_query_var('page') ) {
            $paged = get_query_var('page');
        } else {
            $paged = 1;
        }

        $args = array('post_type' => 'array-portfolio', 'posts_per_page' => 1000, 'paged' => $paged );

        $temp = $wp_query;
        $wp_query = null;
        $wp_query = new WP_Query();
        $wp_query->query( $args );

        while ($wp_query->have_posts()) : $wp_query->the_post();
        $i++;
        if ($i%6==0){
           $class='last';
                                            }
        else {
           $class='';
             }
        ?>
        <li class="col-lg-2"<?php echo $class; ?>><a class="port-image" href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_post_thumbnail( 'port-image' ); ?></a></li>
        <?php endwhile; ?>
        </ul>
        <?php
           $wp_query = null;
           $wp_query = $temp;  // Reset
        ?>

untested:

<ul class="col-lg-12">
  <?php
  $i=0;
  if ( get_query_var('paged') ) {
      $paged = get_query_var('paged');
  } else if ( get_query_var('page') ) {
      $paged = get_query_var('page');
  } else {
      $paged = 1;
  }
  $args = array('post_type' => 'array-portfolio', 'posts_per_page' => 1000, 'paged' => $paged );
  $temp = $wp_query;
  $wp_query = null;
  $wp_query = new WP_Query();
  $wp_query->query( $args );
  <?php
  while ($wp_query->have_posts()) : $wp_query->the_post();
    $i++;
    $class='';
    if ($i%6==0){
      $class='last';
    }
    ?>
    <li class="col-lg-2"<?php echo $class; ?>><a class="port-image" href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_post_thumbnail( 'port-image' ); ?></a></li>
    <?php
      if ($i%6==0){
      ?>
      </ul>
      <ul class="col-lg-12">
      <?php
    } 
  endwhile; ?>
</ul>

first thing you need to fix is the ul needs to be inside the loop. Once inside you nee to use a counter to display the 'ul' tags accordingly. In the untested example i've provided you will see that the 'ul' opening tag is displayed in the first post and then in the at the end of every sixth post.

Additionally I made a counter $countposts to determine which post is the last and displayed another closing div with the argument if $i is equal to $countposts. I hope this finds you well.

            <?php
            $i=0;
 $ireseti=0;
            if ( get_query_var('paged') ) {
                $paged = get_query_var('paged');
            } else if ( get_query_var('page') ) {
                $paged = get_query_var('page');
            } else {
                $paged = 1;
            }

            $args = array('post_type' => 'array-portfolio', 'posts_per_page' => 1000, 'paged' => $paged );

            $temp = $wp_query;
            $wp_query = null;
            $wp_query = new WP_Query();
            $wp_query->query( $args );

            while ($wp_query->have_posts()) : $wp_query->the_post();
            $i++;
            if ($i%6==0){
               $class='last';
                                                }
            else {
               $class='';
                 }
         <?php  if ($ireseti==1){ 
   echo '<ul class="col-lg-12 row">';} ?>
            <li class="col-lg-2"<?php echo $class; ?><a class="port-image" href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_post_thumbnail( 'port-image' ); ?></a></li>
<?php if ($ireseti == 6) {echo '</ul<!--end row-->'
   <?php $ireseti=$ireseti+1;

 if ($ireseti==7){ 
 $ireseti=1;}
elseif ( $countposts == $i ) { echo '</div>';}  ?>
            <?php endwhile; ?>

            <?php
               $wp_query = null;
               $wp_query = $temp;  // Reset
            ?>