Search.php With Pagination Coding
-
Hello everyone,
I’m in need of some simple help. The coding for my search.php is not producing the correct url for the pagination. Currently, the coding is producing the following when you click on the pagination.
https://website.com/?s=topic/page/2/
It should be producing this:
https://website.com/page/2/?s=topic/
Can anyone help me figure out what is wrong with the coding.
<?php get_header(); ?> <div id = "left-side-content"> <div id = "ls_title"> <div id = "sub_title_cat">Search Results</div> </div> <?php if (have_posts()) : while (have_posts()) : the_post(); ?> <div id = "blog_post"> <div id = "blog_thumb"><img src="<?php echo catch_that_image() ?>" width = "100%"></div> <div id = "blog-post-column"> <div id = "post_title"><?php the_category(', '); ?></div> <div id = "post_sub_title"><a>"><?php the_title(); ?></a></div> <div id = "post_desc"><?php echo wp_trim_excerpt(); ?></div> <span class = "post_readmore"><a>">Unplug More</a></span> </div> </div> <?php endwhile; ?> <div id = "title_cat">{ <?php global $wp_query; $total_pages = $wp_query->max_num_pages; if ($total_pages > 1){ $current_page = max(1, get_query_var('paged')); echo paginate_links(array( 'base' => get_pagenum_link(1) . '%_%', 'format' => '/page/%#%/', 'current' => $current_page, 'total' => $total_pages, 'prev_next' => True, )); } ?>} <?php else : ?> <div id = "title_cat"> <div <?php post_class(); ?> id="post-<?php the_ID(); ?>"> <h1>Not Found</h1> </div> <?php endif; ?> </div>
[Moderator Note: Please post code or markup between backticks (not single quotes) or use the code button. Or better still – use a pastebin. Your posted code may now have been permanently damaged by the forum’s parser.]
Thank you,
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Search.php With Pagination Coding’ is closed to new replies.