• wvanderzee

    (@wouter-van-der-zee)


    I’d like to display the next and previous page link when using a custom query. The query list pages with the same parent page (projects). The next and previous page link must link to the next and previous project pages. But currently, they also link to other pages (not only child pages of the parent page (id=14).

    This is the code:

    // set the "paged" parameter
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    
    // start a wp query
    $args = array(
       'post_type' 		=> 'page',
       'post_parent'		=> '14',
       'orderby'		=> 'menu_order',
       'paged' 			=> $paged
    );
    
    $wz_query_project_pages = new WP_Query( $args );
    
    if ( $wz_query_project_pages->have_posts() ) :
    while ( $wz_query_project_pages->have_posts() ) : $wz_query_project_pages->the_post();
    endwhile;
    ?>
    
    <?php previous_post_link(); ?>
    <?php next_post_link(); ?>
    
    <?php
    // end the wp query
    endif;
    ?>

    Any suggestions?

  • The topic ‘Pagination in page template with WP Query’ is closed to new replies.