Reputation:
Pagination not working on category page, the query that i used on category page is below: number of paginate is correct but while I am clicking on that number it redirect to home page where I am wrong please give me solution,
//code below
$cat_ID = get_query_var('cat');
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$article = new WP_Query(array('post_type' => 'post','cat' => cat_ID,
'posts_per_page' => '2', 'paged' => $paged));
while ($article->have_posts()) : $article->the_post();
$post_id = get_the_ID();
// here is my pagination code
$big = 76;
$args = array(
'base' => str_replace($big, '%#%', esc_url(get_pagenum_link($big))),
'format' => '?paged=%#%',
'total' => $article->max_num_pages,
'current' => $paged,
'prev_next' => True,
'prev_text' => __('Previous'),
'next_text' => __('Next'),
'type' => 'list');
echo paginate_links($args);
Upvotes: 1
Views: 233
Reputation: 3
hello friend i have faced this type of problem before and the solution that i came with was
Go to setting and then go to to reading tab there you can see "Blog pages show at most" option adjust the number according to your need or until the pagination starts working
Upvotes: 0
Reputation: 239
$category_link = get_category_link( $category_id ) . '/%_%';
'base' => $category_link,
'format' => 'page/%#%',
'total' => $article->max_num_pages
Upvotes: 0
Reputation: 8819
Change 'format' parameter 'paged' to anything else.
echo paginate_links( array(
...
'format' => '?myparam=%#%',
Then access/get it from your url something like this
$page = (get_query_var('myparam')) ? get_query_var('myparam') : 1;
$slide = new WP_Query(array('post_type' => 'post', 'posts_per_page' => '12', 'paged' => $page));
Upvotes: 0
Reputation: 238
<?php while (have_posts()):the_post(); ?>
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$slide = new WP_Query(array('post_type' => 'post', 'posts_per_page' => '12', 'paged' => $paged));
if ($slide->have_posts()) : while ($slide->have_posts()) : $slide->the_post();
$post_id = get_the_ID();
//show contents here
$big = 76;
$args = array(
'base' => str_replace($big, '%#%', esc_url(get_pagenum_link($big))),
'format' => '?paged=%#%',
'total' => $slide->max_num_pages,
'current' => $paged,
'prev_next' => True,
'prev_text' => __('Previous'),
'next_text' => __('Next'),
'type' => 'list');
// ECHO THE PAGENATION
echo paginate_links($args);
Upvotes: 1