Forums Forums Search & Filter Pro Pagination on a Search Page

Tagged: 

Viewing 2 posts - 1 through 2 (of 2 total)
  • Anonymous
    #251413

    Hello,

    I am having issues getting pagination on a search template page. I have used the following code to get pagination working on my custom post archives.

    $foundationPosts = new WP_Query(array
    (‘paged’=> get_query_var(‘paged’,1),
    ‘post_type’ => ‘how_to_videos’,

    <?php echo paginate_links(array(
    ‘total’ => $foundationPosts ->max_num_pages
    )); ?>

    I am not sure how to do this on the search template php file. Any help would be appreciated.

    Thanks,

    Adam

    Trevor
    #251465

    Try something a lot simpler to start with, like this:

    	<div class="pagination">
    		
    		<div class="nav-previous"><?php next_posts_link( 'Older posts', $query->max_num_pages ); ?></div>
    		<div class="nav-next"><?php previous_posts_link( 'Newer posts' ); ?></div>
    	</div>

    This assumes that your main query results array is called $query

    This code does not run an extra query, as you can see.

Viewing 2 posts - 1 through 2 (of 2 total)