wp_query’s pagination not working

I don’t know why following code is not working. Wp_query loop with paginate_links is showing right number of pages in paginantion but on clicking them or on next the content of page does not change. Please help.

<?php

get_header();

$paged1 = isset( $_GET['paged1'] ) ? (int) $_GET['paged1'] : 1;
$args1 = array(
'paged'          => $paged1,
'posts_per_page' => 3,
);
$query1 = new WP_Query( $args1 );

while ( $query1->have_posts() ) : $query1->the_post();
the_title();
echo '<br>';
the_category(' ');
the_excerpt();
echo '<hr>';
endwhile;

$pag_args1 = array(
'format'   => '?paged1=%#%',
'current'  => $paged1,
'total'    => $query1->max_num_pages,
'add_args' => array( 'paged1' => $paged1 )
);
echo paginate_links( $pag_args1 );

get_sidebar();
get_footer();

?>

Related posts

Leave a Reply