Search page with custom pagination doesn’t work
-
Hi, I’m pretty new to wordpress, and I ran into this problem. I used custom pagination where the user can input number of the page they want to jump to. Pagination works fine when you click next or previous link, but when I input a number, just goes to home page.
URL changes the searched query (to search for “test” URL on page 3 should be “/page/3/?s=test”, but goes to home page with URL “/page/3/?paged=3”.Code I used to call the pagination:
<div class="override-pagination"> <?php global $wp_query; $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; $max_num_pages = $wp_query->max_num_pages; ?> <form class="pagination-with-input" novalidate> <?php $previous_page = get_previous_posts_page_link(); if ($previous_page && $paged > 1) { ?> <a class="pagination-previous" href="<?php echo $previous_page; ?>"><svg xmlns="https://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-chevron-left"><polyline points="15 18 9 12 15 6"></polyline></svg></a> <?php } ?> <span class="pagination-current"> <input type="number" name="paged" min="1" max="<?php echo $max_num_pages; ?>" value="<?php echo $paged; ?>"> </span> <span class="pagination-seperator">of</span> <span class="pagination-max"><?php echo $max_num_pages; ?></span> <?php $next_page = get_next_posts_page_link(); if ($next_page && $paged < $max_num_pages) { ?> <a class="pagination-next" href="<?php echo $next_page; ?>"><svg xmlns="https://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-chevron-right"><polyline points="9 18 15 12 9 6"></polyline></svg></a> <?php } ?> </form> </div>
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘Search page with custom pagination doesn’t work’ is closed to new replies.