Domanda

I can get all my posts in the following loop to show except the last? There should be ten posts but it's only showing nine?

        <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>
È stato utile?

Soluzione

If you're offsetting each query to not show the previous 3 posts, your offsets are set wrong.

Try an offset: 3 on staff02_args and increment each succeeding query from there.

3, 6, 9

Instead of

4, 7, 10

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a wordpress.stackexchange
scroll top