Ready to get started?Download WordPress


Pull The 4th, 5th, 6th Most Recent Post (4 posts)

  1. stephengale
    Posted 1 year ago #

    I have 2 columns on my website - the left column pulls the 1st, 2nd, 3rd most recent posts from my WordPress Site, and the right is meant to pull the 4th, 5th, 6th most recent posts.

    I am using the following code to pull the first 3, but I can't figure out how to just pull the 4th, 5th and 6th most recent for the right column.

    <?php while (have_posts()): the_post(); ?>
              <h2><?php the_title(); ?></h2>
              <?php the_content(); ?>
              <?php endwhile; ?>

    Would anyone be able to help me please?


  2. Andrew
    Forum Moderator
    Posted 1 year ago #

    Are you sure your 4th, 5th and 6th are publicly visible?

  3. stephengale
    Posted 1 year ago #

    They are visible. The problem is I'm using the same code for both columns at the moment so they are both pulling the same 3 most recent posts.

    Left needs: Latest Post, 2nd-Latest Post, 3rd-Latest Post
    Right needs: 4th-Latest Post, 5th-Latest Post, 6th-Latest Post

    Sorry if I'm not making much sense!

  4. alchymyth
    Forum Moderator
    Posted 1 year ago #

    two possibiities:

    one single loop, but with coding to close the first section after 3 posts, and opening the new section for further three posts; better for pagination;

    add a query before the loop; use a 'posts_per_page' parameter for both loops; use the 'offset' parameter in the query for the second loop;

Topic Closed

This topic has been closed to new replies.

About this Topic