Forums › Forums › Search & Filter Pro › Pagination not updating
Tagged: advanced custom fields, custom post types
- This topic has 13 replies, 3 voices, and was last updated 6 years, 1 month ago by Anonymous.
-
Anonymous(Private) October 5, 2018 at 2:54 pm #190212
Hi,
I have a WP_Query that displays a custom post type… I have it paginating, works great. However now I have Search and Filter Pro running, with display results set as “custom” and then linking to the site URL… the pagination WORKS, but the numbers don’t update. So when I’m on page 2, the pagination links still show as page 1.
Here’s the code:
<?php $paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1; $query = new WP_Query( array( 'post_type' => 'insights', 'search_filter_id' => '753', 'orderby'=>'title', 'order'=>'ASC', 'posts_per_page' => 5, 'paged' => $paged ) ); ?> <?php echo do_shortcode('[searchandfilter id="753"]');?> <div class="row"> <div id="results"> <?php if ( $query->have_posts() ) : ?> <div class="col-md-12"> <?php while ( $query->have_posts() ) : $query->the_post(); ?> <?php if(get_field('insights_type') != 'Blog') : ?> <div class="insights"> <div class="insights_single"> <div class="first-row"> <?php if(get_field('insights_type') === 'Alerts') : ?> <img src="/wp-content/themes/solicitor-child/img/Alerts-icon.png" class="insight-icon"> <?php elseif(get_field('insights_type') === 'Articles') : ?> <img src="/wp-content/themes/solicitor-child/img/Articles-icon.png" class="insight-icon"> <?php elseif(get_field('insights_type') === 'Events') : ?> <img src="/wp-content/themes/solicitor-child/img/Events-icon.png" class="insight-icon"> <?php elseif(get_field('insights_type') === 'News') : ?> <img src="/wp-content/themes/solicitor-child/img/News-icon.png" class="insight-icon"> <?php elseif(get_field('insights_type') === 'Newsletters') : ?> <img src="/wp-content/themes/solicitor-child/img/Newsletters-icon.png" class="insight-icon"> <?php elseif(get_field('insights_type') === 'Press Releases') : ?> <img src="/wp-content/themes/solicitor-child/img/Press-Releases-icon.png" class="insight-icon"> <?php elseif(get_field('insights_type') === 'White Papers') : ?> <img src="/wp-content/themes/solicitor-child/img/White-Papers-icon.png" class="insight-icon"> <?php endif;?> <span class="insight-type"><?php the_field('insights_type');?></span>, <span class="insight-date"><?php echo get_the_date();?></span> </div> <?php if (get_field('attached_document')) : ?> <a href="<?php the_field('attached_document');?>" target="_blank"> <div class="insight-title"><?php the_title(); ?></div> </a> <?php elseif(get_field('remote_url')) : ?> <a href="<?php the_field('remote_url');?>" target="_blank"> <div class="insight-title"><?php the_title(); ?></div> </a> <?php else : ?> <a href="<?php the_permalink();?>"> <div class="insight-title"><?php the_title(); ?></div> </a> <?php endif;?> <div class="insight-summary"><p><?php the_field('short_summary');?></p></div> </div> </div> <?php endif;?> <?php endwhile; wp_reset_postdata(); ?> </div> <?php else : ?> No results <?php endif; ?> </div> <div class="pagination"> <?php echo paginate_links( array( 'base' => str_replace( 999999999, '%#%', esc_url( get_pagenum_link( 999999999 ) ) ), 'total' => $query->max_num_pages, 'current' => max( 1, get_query_var( 'paged' ) ), 'format' => '?sf_paged=%#%', 'show_all' => false, 'type' => 'plain', 'end_size' => 2, 'mid_size' => 1, 'prev_next' => true, 'prev_text' => sprintf( '<i></i> %1$s', __( 'Previous Page', 'text-domain' ) ), 'next_text' => sprintf( '%1$s <i></i>', __( 'Next Page', 'text-domain' ) ), 'add_args' => false, 'add_fragment' => '', ) ); ?> </div> </div> </div>
Not sure what I’m doing wrong.
Anonymous(Private) October 8, 2018 at 9:50 am #190311Hi,
Thanks for the reply. The extra closing divs were my fault, I copy and pasted the copy but there are additional containers on the overall page (not related to this).
I put the pagination inside the #results container, and the pagination links do not update still. The pagination itself works, it changes the posts displayed to page two, and the URL in the browser bar updates, but the pagination stays as:
1 2 next page
On page 2, if I click “next page” it goes back to the first page.
Trevor(Private) October 8, 2018 at 2:28 pm #190366For Infinite Scroll to work, the HTML structure would look like this:
<div class="ajax-container"> <div class="infinite-scroll-container"> <div class="individual-post-container">...<</div> ... and more posts </div> <div class="pagination"> ... links </div> </div>
Your classnames would be different, but these would then match what is in the form settings. Is that what you have as the structure?
Trevor(Private) October 10, 2018 at 11:19 am #190610Did you try this using our shortcode method? Your code from:
<div class="row"> <div id="results"> <?php if ( $query->have_posts() ) : ?>
Could replace the code in our standard results.php, see here for customizing the results.php file:
https://searchandfilter.com/documentation/search-results/using-a-shortcode/#customising-the-results
-
AuthorPosts