Forums › Forums › Search & Filter Pro › Pagination doesn’t” work properly
Tagged: pagination
- This topic has 14 replies, 2 voices, and was last updated 4 years, 7 months ago by Trevor.
-
Anonymous(Private) April 23, 2020 at 12:10 pm #241098
Pagination doesn’t” work properly
Hello. I am using search and Filter pro and having problem with pagination.
It seems to work fine but when I go back to page 1, only page 1 doesn’t have the link(doesn’t have href).
And it happens only PC view, if I check with SP, it works just fine.Here is My code.
(*I use original code for pagination, but if tried to use WP-PageNavi(same as your template of results.php) Page 1 doesn’t work either.)[results.php]
<?php if ($query->have_posts()) : ?> <?php while ($query->have_posts()) { $query->the_post(); ?> <a href="<?php the_permalink(); ?>" class="sresult"> <?php if (has_post_thumbnail()) { echo '<p class="sresult-thumb">'; the_post_thumbnail(); echo '</p>'; } ?> <h2 class="sresult-ttl"><?php the_title(); ?></h2> <p class="sresult-name"><?php the_field('interview_name'); ?> </p> <?php $fields = get_field_objects($post_id); $dir_array = $fields["interview_occupation"]["choices"]; $check = get_field('interview_occupation'); $value = $check[0]; ?> <p class="sresult-job"><?php echo $dir_array[$value]; ?></p> </a><!-- /.sresult --> <?php } ?> <div class="spagination"> <?php if ( function_exists( 'pagination' ) ) : pagination( $query->max_num_pages, get_query_var( 'paged' ) ); endif; ?> </div><!-- /.spagination --> <?php else : ?> <div class="snoresult"> <p>No results</p> </div><!-- /.snoresult --> <?php endif; ?> </div><!-- /. search-filter-results -->
[functions.php]
function pagination( $pages, $paged, $range = 2, $show_only = false ) { $pages = ( int ) $pages; $paged = $paged ?: 1; //表示テキスト $text_first = "« FIRST"; $text_before = "PREV"; $text_next = "NEXT"; $text_last = "LAST »"; if ( $show_only && $pages === 1 ) { echo '<div class="pagination"><span class="current pager">1</span></div>'; return; } if ( $pages === 1 ) return; if ( 1 !== $pages ) { echo '<div class="pagination"><span class="page_num">Page ', $paged ,' of ', $pages ,'</span>'; if ( $paged > $range + 1 ) { // FIRST echo '<a href="', get_pagenum_link(1) ,'" class="first js_redirect_to_pagenum_link">', $text_first ,'</a>'; } if ( $paged > 1 ) { // PREV echo '<a href="', get_pagenum_link( $paged - 1 ) ,'" class="prev js_redirect_to_pagenum_link">', $text_before ,'</a>'; } for ( $i = 1; $i <= $pages; $i++ ) { if ( $i <= $paged + $range && $i >= $paged - $range ) { // $paged +- $range 以内であればページ番号を出力 if ( $paged === $i ) { echo '<span class="current pager">', $i ,'</span>'; } else { echo '<a href="', get_pagenum_link( $i ) ,'" class="pager js_redirect_to_pagenum_link">', $i ,'</a>'; } } } if ( $paged < $pages ) { // NEXT echo '<a href="', get_pagenum_link( $paged + 1 ) ,'" class="next js_redirect_to_pagenum_link">', $text_next ,'</a>'; } if ( $paged + $range < $pages ) { // LAST echo '<a href="', get_pagenum_link( $pages ) ,'" class="last js_redirect_to_pagenum_link">', $text_last ,'</a>'; } echo '</div>'; } }
The website is my client site so I cannot give you the link. But if you provide me a contact address that I can send you directly or hide this topic somehow, I can give you the link of testsite.
Regards,
-
AuthorPosts