Forums › Forums › Search & Filter Pro › Issues with Pagination
Tagged: `
- This topic has 1 reply, 2 voices, and was last updated 8 years, 9 months ago by Ross.
-
Anonymous(Private) February 8, 2016 at 7:35 pm #36511
Hello,
I’m running into an issue with pagination on the results page. The “next_posts_link()” and “previous_posts_link()” pagination that comes with the default results.php file works, but it doesn’t seem to work when I try to use the paginate_links() function. When the page is initially loaded, the pagination links work. For example, the links’ href are “?sf_paged=2” and so on. But, when I click on a page link in the pagination and the new page loads, the pagination links no longer work. they now all have hrefs as “?sf_action=get_results” and don’t link anywhere. Pagination links also won’t work when a filter is chosen. all the pagination links become “?sf_action=get_results&_sft_classification=oversight-and-development” or whatever the chosen filter is.
For reference, here is the pagination code I’m using:
<?php global $wp_query; $big = 999999999; if ($query->max_num_pages > 1) { echo '<div class="pagination">'; echo paginate_links(array( 'base' => str_replace($big, '%#%', get_pagenum_link($big)), 'format' => '?paged=%#%', 'current' => max(1, get_query_var('paged')), 'total' => $query->max_num_pages, 'prev_text' => __('< PREV'), 'next_text' => __('NEXT >'), )); echo '</div>'; }
Thank you for your help.
Travis
Ross Moderator(Private) February 8, 2016 at 11:24 pm #36519Hey Travis are you using the shortcode method to display results? (hence using the results.php)? Then in this case, you will notice that they actually pass the custom query to the pagination function(s).
Therefor you need to use the pagination variable too:
So
'current' => max(1, get_query_var('paged')),
Should become something like:
'current' => max( 1, $query->query['paged'] ),
So the paged var inside the custom query (the shortcode method) is used rather than the global var.
Thanks
-
AuthorPosts