• Resolved jeanmeslier

    (@jeanmeslier)


    OK, I have looked at multiple solutions for this and no matter what I try it does not work. I cannot get this template to paginate. This is my code:

    <?php
    $page = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $temp = $multiPage;
    $multiPage = null;
    $multiPage = new WP_Query( array( 'paged' => $paged, 'posts_per_page' => 3,'post_type' => 'publications' ));
    			while ($multiPage->have_posts()) : $multiPage->the_post(); ?>
    	<div class="post">
    ....Do loop stuff
    </div>
    <?php endwhile; // end of the loop. ?>	
    
    <div class="pagenav">
    <div class="alignleft"><?php previous_posts_link('Previous') ?></div>
    <div class="alignright"><?php next_posts_link('Next') ?></div>
    </div>
    <?php $multiPage = null; $multiPage = $temp; ?>

    I have dug through many existing tickets and offered solutions and no matter what I try I cannot get the links to show up. If anyone can help it would be much appreciated.

    You can see the live version of this loop running here: https://thenewobjectivity.com/twaas/?page_id=87

    As you can see, the links are not even generated. I’m not worried about resolution through permalinks at this time. I will cross that bridge when I come to it. I just want the links generated. Please help! I’ve been beating my head against this wall for hours.

    Thanks,

    Josh

Viewing 2 replies - 1 through 2 (of 2 total)
  • Try using this same code, but different style:

    <?php
    $page = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $temp = $wp_query;
    $wp_query = null;
    $wp_query = new WP_Query();
    $wp_query -> query('post_type=publications&showposts=3'.'&paged='.$paged);
    	while ($wp_query->have_posts()) : $wp_query->the_post(); ?>
    	<div class="post">
            ....Do loop stuff
            </div>
    <?php endwhile; // end of the loop. ?>
    
    <div class="pagenav">
    <div class="alignleft"><?php previous_posts_link('Previous') ?></div>
    <div class="alignright"><?php next_posts_link('Next') ?></div>
    </div>
    
    <?php $wp_query = null; $wp_query = $temp; ?>
    Thread Starter jeanmeslier

    (@jeanmeslier)

    A very late reply, but thanks vanrithysok, that worked!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Pagination with wp_query and custom post type’ is closed to new replies.