Pagination

Forums › Forums › Search & Filter Pro › Pagination

Tagged: 

Viewing 4 posts – 1 through 4 (of 4 total)
  • Anonymous
    #13678

    Hi,

    I’m looking to add in pagination with numbers of pages to the template file in my theme folder. When I try to add in the same one I’m using elsewhere is doesn’t seem to work and I’m wondering what I need to change in it to get it working.

    <?php
    global $wp_query;
    
    $big = 999999999; // need an unlikely integer
    $translated = __( 'Page', 'mytextdomain' ); // Supply translatable string
    
    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,
            'before_page_number' => '<span class="screen-reader-text">'.$translated.' </span>'
    ) );
    ?>

    Any help is much appreciated.

    Ross Moderator
    #13681

    Hey Jordan

    If you are displaying your results “as archive” – then this behaves just like an archive template – so any problems you have with pagination will likely also be present in other areas of your site – or you could check archive.php to see how pagination is set up there.

    Saying that, this plugin supports the wp_page_navi plugin, which I guess has the numbering that you need?

    Thanks

    Anonymous
    #13686

    Fantastic, I’ll try this plugin.

    The archives are great to use, but with the way I’m needing the site to work the shortcodes seem more flexible for the end user. That way I can use a single template for the various pages that have to be generated and just have them place the shortcode in a custom field to generate a new listing.

    Thanks again.

    Ross Moderator
    #13690

    Ah I see

    You will find that with the shortcode method, it is creating a custom loop – which doesn’t work out of the box with most pagination, normally there are one or two additional steps to make pagination work with custom queries, but this depends on how you are implementing this.

    The sample results.php template has the code in it for the wp_page_navi plugin so if its enabled it should just display.

    Thanks

Viewing 4 posts – 1 through 4 (of 4 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.