WordPress Pagination Script Issue
-
Hello Everyone ??
I have question regarding pagination script. Currently I am using Simple Pagination for display custom post type records.
Everything is working good but when I pass some variable from URL and click to second page, next record is not displaying. Why I am not getting second results.
I am getting result if URL is:
https://localhost/example/my-search/
or
https://localhost/example/my-search/page/2/I am not getting result if URL is:
https://localhost/example/my-search/page/2/?books=Internet&submit=searchPlease I need your help to fix this issue.
My Code:
<?php $args = array ( 'post_type' => 'book', 'post_status' => 'publish', 'paged' => $paged, 'posts_per_page' => -1 ); $temp = $wp_query; //Assign ordinal query to temp variable for later use $wp_query = null; $wp_query = new WP_Query($args); echo '<div class="result-count">Showing all '.$wp_query->post_count.' results</div>'; if ( $wp_query->have_posts() ) : while ( $wp_query->have_posts() ) : $wp_query->the_post(); echo '<div class="entry-content">'; the_title(); echo'</div>'; endwhile; endif; echo '</div>'; ?> <nav> <?php if(function_exists('wp_simple_pagination')) { wp_simple_pagination(); } ?> <?php $wp_query = null; $wp_query = $temp; // Reset ?> </nav>
- The topic ‘WordPress Pagination Script Issue’ is closed to new replies.