Forums Forums Search & Filter Pro Pagination not updating

Viewing 10 posts - 1 through 10 (of 14 total)
  • Anonymous
    #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.

    Trevor
    #190245

    That code has one more closing </div> than opening divs, I think. If your Ajax container is #results, the pagination is outside of that, and thus will not get updated.

    Anonymous
    #190311

    Hi,

    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.

    Anonymous
    #190313

    Also on page 2, “1” in the pagination is not a link (as if it was on page 1), and “2” in the pagination also links back to the root /insights/ URL. =/

    Trevor
    #190366

    For 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?

    Anonymous
    #190368
    This reply has been marked as private.
    Trevor
    #190376
    This reply has been marked as private.
    Anonymous
    #190512
    This reply has been marked as private.
    Trevor
    #190610

    Did 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

    Anonymous
    #190612

    Well I have multiple pages that pull in different post type info and use different search forms, so I’d rather get it working the way it should with the templates I have setup rather than customising your templates.

Viewing 10 posts - 1 through 10 (of 14 total)