WordPress.org

Forums

Custom Post Type Pagination (3 posts)

  1. newtoncircle
    Member
    Posted 4 years ago #

    I am using custom post type that is hierarchical.

    I have no trouble excluding children from the query by using:
    parent=0

    This exclusion, however, doesn't apply to the next_posts_link and previous_posts_link. I want to navigate using only the parent.

    Here is my code:

    <?php $showposts = new WP_Query('post_type=events&post_parent=0'); while($showposts->have_posts()) : $showposts->the_post(); ?>
    <?php the_title( '<h2><a href="' . get_permalink() . '" title="' . the_title_attribute( 'echo=0' ) . '" rel="bookmark">', '</a></h2>' ); ?>
    <div>
      <?php the_content(); ?>
      <p><?php next_post_link('%link', '« Newer Issue' ) ?></p>
      <p><?php previous_post_link('%link', 'Older Issue »') ?></>
    </div>
    <?php endwhile; ?>
  2. alchymyth
    Forum Moderator
    Posted 4 years ago #

    is it on purpose that you are using the link to the next/prev single post?
    i.e. `next_post_link() http://codex.wordpress.org/Function_Reference/next_post_link

    in your text, you are talking about:
    next_posts_link()
    http://codex.wordpress.org/Function_Reference/next_posts_link

  3. newtoncircle
    Member
    Posted 4 years ago #

    sorry: typo

    I am using next_post_link.

    I was able to download a plugin called "Ambrosite Next/Previous Post Link Plus" that allowed me a solution.

    This plugin allows a next_post_link_plus command that works just fine.

    I try to avoid plugins, though.

Topic Closed

This topic has been closed to new replies.

About this Topic