Pagination Alwaus Return to Page 1

Forums › Forums › Search & Filter Pro › Pagination Alwaus Return to Page 1

Tagged: 

Viewing 10 posts – 1 through 10 (of 11 total)
  • Anonymous
    #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=temp

    I 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
    #37433

    Change 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
    #37445

    Hi 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
    #37452

    Hey 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

    Anonymous
    #37457
    This reply has been marked as private.
    Ross Moderator
    #37461
    This reply has been marked as private.
    Anonymous
    #37463
    This reply has been marked as private.
    Ross Moderator
    #37730
    This reply has been marked as private.
    Anonymous
    #37738

    Hi 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
    #37909

    Yup you should just be able to remove the old pagination and use the one of the ones I supplied ๐Ÿ™‚

Viewing 10 posts – 1 through 10 (of 11 total)

Search & Filter Support
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.

We also use cookies to store items in your cart as well as allowing your to login on the site.

You can adjust all of your cookie settings by navigating the tabs on the left hand side.

By continuing to use this site, you also agree to our Privacy Policy.