偏移量循环不显示最后一个柱子

时间:2014-12-10 作者:nobot-z

我可以在下面的循环中显示我的所有帖子,除了最后一篇?应该有十个帖子,但只显示了九个?

        <div class="row staff-board">

          <?php $staff01_args = array(
            \'post_type\'      => \'staffboard\',
            \'posts_per_page\' => 3,
            \'cat\' => 4 ); ?>

            <?php $the_query = new WP_Query( $staff01_args ); ?>

            <?php if ( $the_query->have_posts() ) :
              while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
              <div class="large-4 medium-4 small-12 columns staff">
                <?php the_post_thumbnail(\'small-portrait\'); ?>
                <?php the_content(); ?>
              </div><!-- /large-4 -->
            <?php endwhile; ?>
            <?php wp_reset_postdata(); ?>
          <?php endif; ?>

        </div>



        <div class="row staff-board">

          <?php $staff02_args = array(
            \'post_type\'      => \'staffboard\',
            \'posts_per_page\' => 3,
            \'offset\' => 4,
            \'cat\' => 4 ); ?>

            <?php $the_query = new WP_Query( $staff02_args ); ?>

            <?php if ( $the_query->have_posts() ) :
              while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
              <div class="large-4 medium-4 small-12 columns staff">
                <?php the_post_thumbnail(\'small-portrait\'); ?>
                <?php the_content(); ?>
              </div><!-- /large-4 -->
            <?php endwhile; ?>
            <?php wp_reset_postdata(); ?>
          <?php endif; ?>

        </div>

        <div class="row staff-board">

          <?php $staff03_args = array(
          \'post_type\'      => \'staffboard\',
          \'posts_per_page\' => 3,
          \'offset\' => 7,
          \'cat\' => 4 ); ?>

          <?php $the_query = new WP_Query( $staff03_args ); ?>

          <?php if ( $the_query->have_posts() ) :
            while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
            <div class="large-4 medium-4 small-12 columns staff">

              <?php the_post_thumbnail(\'small-portrait\'); ?>
              <?php the_content(); ?>
            </div><!-- /large-4 -->
          <?php endwhile; ?>
          <?php wp_reset_postdata(); ?>
        <?php endif; ?>

        </div>

        <div class="row staff-board">

          <?php $staff04_args = array(
          \'post_type\'      => \'staffboard\',
          \'posts_per_page\' => 3,
          \'offset\' => 10,
          \'cat\' => 4 ); ?>

          <?php $the_query = new WP_Query( $staff04_args ); ?>

          <?php if ( $the_query->have_posts() ) :
            while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
            <div class="large-4 medium-4 small-12 columns staff">
              <?php the_post_thumbnail(\'small-portrait\'); ?>
              <?php the_content(); ?>
            </div><!-- /large-4 -->
          <?php endwhile; ?>
          <?php wp_reset_postdata(); ?>
        <?php endif; ?>

        </div>

1 个回复
最合适的回答,由SO网友:Rich 整理而成

如果将每个查询的偏移量设置为不显示前3篇文章,则偏移量设置错误。

尝试offset: 3 在…上staff02_args 并从此处递增每个后续查询。

3、6、9

而不是

4、7、10

结束

相关推荐