• Basically, what I want to do is create a next_post_link, but for WP Pages. Let’s say this is my page hierarchy:

    Page A
    Page B
    Page C

    While I’m viewing Page A, I want to display a link and a preview image of Page B. While viewing Page B, I want to view the same for Page C, and so on down the line.

    Here’s my code so far:

    <?php
    global $post;
    $currentpage = get_the_ID();
    $parent = $post->post_parent;
    $args=array(
    'post_type'=>'page',						'post__not_in'=>array($currentpage),				'post_parent' => $parent,
    'orderby' => 'title',
    'order' => 'ASC',
    'showposts' => 1,
    );
    
    $siblings = new WP_Query($args);
    ?>
    <div class="next-page">
    <?php while ($siblings->have_posts()) : $siblings->the_post(); ?>
    <!--do some stuff-->
    <?php endwhile ;?>

    What I’m missing is some sort of offset, or “start” parameter, so that it only return the immediate sibling of the current page.

    I appreciate any help. Thanks.

  • The topic ‘Using query_posts to return a page’s immediate sibling’ is closed to new replies.