Forums › Forums › Search & Filter Pro › Pagination Alwaus Return to Page 1
Tagged: pagination
- This topic has 10 replies, 2 voices, and was last updated 8 years, 9 months ago by Anonymous.
-
Anonymous(Private) February 19, 2016 at 11:27 am #37413
Hi !
I have a problem : pagination only return to page 1.
when I click on page 2, I get on results page 1, etc.Page 1 => http://www.exemple.com/?sfid=2622&_sft_category=temp
Page 2 => http://www.exemple.com/?sfid=2622&_sft_category=tempI tried to resolve the problem by myself, without success.
Note : the pagination works with archive page.
My archive Loop code (results are displayed as archive):
if ( have_posts() ) : while ( have_posts() ) : the_post(); get_template_part( 'inc/partials/content', 'blog-grid' ); endwhile; mediaphase_pagination(); else: get_template_part( 'inc/partials/content', 'none' ); endif;
And my MediaPhase theme native pagination :
function mediaphase_pagination() { global $wp_query; if ( $wp_query->max_num_pages < 2 ) { return; } $big = 999999999; // need an unlikely integer echo '<div class="pagination">'; echo paginate_links( array( 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), 'format' => '?paged=%#%', 'current' => max( 1, get_query_var( 'paged' ) ), 'total' => $wp_query->max_num_pages ) ); echo '</div>'; }
I tested with all plugin deactivated except Search & Filter Pro and ACF, and I don’t have anu function in my function.php child theme. All is last version (WordPress, S&FPro etc…)
Do you have any idea about this ?
Thanks for your support ๐
Ross Moderator(Private) February 19, 2016 at 2:12 pm #37433Change your pagination to:
function mediaphase_pagination() { global $wp_query; if ( $wp_query->max_num_pages < 2 ) { return; } $big = 999999999; // need an unlikely integer echo '<div class="pagination">'; echo paginate_links( array( 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), 'format' => '?paged=%#%', 'current' => max( 1, $wp_query->query['paged'] ), 'total' => $wp_query->max_num_pages ) ); echo '</div>'; }
Notice this line has changed:
'current' => max( 1, $wp_query->query['paged'] ),
So you now get the current paged variable from the query directly, rather than a query var.
Thanks
Anonymous(Private) February 19, 2016 at 3:35 pm #37445Hi Ross; thank you for your quick support !
I tested, created a new functions in my functions.php, implemented it in my search and filter page and it still doesn’t work.
I made a short video demo for you so you can see => I make a search first, then try pagination (and it doesn’t work), and then I inspect the theme file and the functions.php
Did I miss something ?
Thanks you again !
Ross Moderator(Private) February 19, 2016 at 4:15 pm #37452Hey there
Actually I made a mistake in my code sample, it should be:
max( 1, $wp_query->query_vars['paged'] ),
Notice the different
query_vars
If you are still having issues after this please send a link in a private message ๐
Thanks
Ross Moderator(Private) February 23, 2016 at 12:14 pm #37730This reply has been marked as private.Anonymous(Private) February 23, 2016 at 12:40 pm #37738Hi Ross, thanks for your custom support !
So I took a look at your hidden pagination and it works as expected (number works, links works, next/previous buttons works).
Does it means that I could replace the original pagination by yours ?
Or is there any other problem that should be corrected ?I wonder if it could be a filter because because I don’t see any in the orignal pagination function, but maybe it is a wordpress one. I tried deactivated the plugins and, if there is a problem, it probably come from the theme, indeed.
Thanks for your infos !
Ross Moderator(Private) February 25, 2016 at 10:08 am #37909Yup you should just be able to remove the old pagination and use the one of the ones I supplied ๐
-
AuthorPosts