WordPress.org

Ready to get started?Download WordPress

Forums

Pagination on custom post types (2 posts)

  1. drummy
    Member
    Posted 4 years ago #

    Hello everyone.
    I've set up two custom post types. For the sake of the example, I will call them 'left' and 'right'.

    I have made an index.php in which I want to achieve the following:

    1. It should loop through the 'left' posts in the left div and
    2. It should loop through the 'right' posts in the right div.
    3. After every 5 posts it should display a "older posts" link.

    From the codex I've been able to find this loop that I use for both (with 'left' and 'right' post types respectively):

    $loop = new WP_Query( array( 'post_type' => 'left', 'posts_per_page' => 10 ) );
    while ( $loop->have_posts() ) : $loop->the_post();
      the_title();
      echo '<div class="entry-content">';
      the_content();
      echo '</div>';
    endwhile;

    It goes through the posts just fine. But I don't know how to make it insert the "older posts" link every 5 posts.

    Can anyone help me out?

  2. MichaelH
    Member
    Posted 4 years ago #

    See the example of A Page of Posts of a custom post type in the Pages article.

Topic Closed

This topic has been closed to new replies.

About this Topic