Forums Forums Search & Filter Pro Pagination on custom page

Tagged: 

Viewing 6 posts - 1 through 6 (of 6 total)
  • Anonymous
    #271364

    Hi,
    I have set a search form for a custom page.

    Everything is ok with the infinite scroll setting. But, with pagination, clicking on pagination links keep reloading the first 6 elements.

    Here is my code :

    <div class="videos flex flex__wrap" id="ajax-results">
    <?php
    $paged = ( get_query_var( 'paged' ) ) ? absint( get_query_var( 'paged' ) ) : 1;
    do_action("search_filter_query_posts", 1605);
    while(have_posts()):
    	the_post();
    	echo '<div>';
    	get_template_part('parts/portrait', 'box');
    	echo '</div>';
    endwhile; ?>
    </div>
    <div class="pagination">
    <?php 
    echo paginate_links( array(
    	'base'         => str_replace( 999999999, '%#%', esc_url( get_pagenum_link( 999999999 ) ) ),
    	'current'      => max( 1, get_query_var( 'paged' ) ),
    	'format'       => '?paged=%#%',
    	'show_all'     => false,
    	'type'         => 'plain',
    	'end_size'     => 2,
    	'mid_size'     => 1,
    	'prev_next'    => true,
    	'prev_text'    => sprintf( '<i></i> %1$s', __( '&larr;', 'text-domain' ) ),
    	'next_text'    => sprintf( '%1$s <i></i>', __( '&rarr;', 'text-domain' ) ),
    	'add_args'     => false,
    	'add_fragment' => '',
    ) );
    ?>
    </div>

    Could you help me please ?
    Thanks

    Trevor
    #271369

    Are you able to send me a live link/URL to your search page so I can take a look?

    Would you be opposed to using a free pagination plugin?

    Have you looked at the exemplar results.php file in our plugin templates folder (designed for use with our shortcode method, but is editable – see our documentation at https://searchandfilter.com/documentation/search-results/using-a-shortcode/#customising-the-results) …

    … and you could simply put your code into that (a lot of which you would not need).

    Anonymous
    #271371
    This reply has been marked as private.
    Anonymous
    #271373

    Trevor,
    I followed your advice and change the basic loop with a custom WP_Query… And it works.
    But one bug is still here : pagitation count is not refreshed with ajax reload of the results.

    Thanks again for your help

    Anonymous
    #271375

    Ok, just found the solution.
    Didn’t read this in the documentation : pagination as to be inside the ajax selector set in admin.
    Everything works perfectly now.

    Thanks again for your help.

    Trevor
    #271421

    Thanks for getting back to me. I will close this thread for now.

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