How to add Custom pagination in wordpress


Staff member
i have created custom theme in wordpress.
I want to add custom pagination to my custom post template which is INDEX.PHP

Can you please check what is wrong in pagination script. actually i have set 4 post limit and there around 8 posts in my blog.. when click on 2 pagination, it won't move to next page...

<div class="snippet" data-lang="js" data-hide="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override">
&lt;?php get_header(); ?&gt;

$paged = ( get_query_var( 'paged' ) ) ? absint( get_query_var( 'paged' ) ) : 1;

// WP_Query arguments
$args = array (
    'post_type'              =&gt; the_post(),
    'posts_per_page'         =&gt; '3',
    'paged' =&gt; $paged

// The Query
$cquery = new WP_Query( $args );
while ( $cquery-&gt;have_posts() ) : $cquery-&gt;the_post();
&lt;div class="row"&gt;
                     &lt;div class="img"&gt;&lt;a href="&lt;?php the_permalink() ?&gt;" class="imgPos"&gt;&lt;?php the_post_thumbnail('full'); ?&gt;&lt;/a&gt;&lt;/div&gt;
                        &lt;div class="text"&gt;
                         &lt;h2&gt;&lt;a href="&lt;?php the_permalink() ?&gt;" style="color:#545454;"&gt;&lt;?php the_title(); ?&gt;&lt;/a&gt;&lt;/h2&gt;
                            &lt;h3 style="line-height: 1px;"&gt;&lt;span class="floatL"&gt;By &amp;nbsp;&lt;/span&gt; &lt;span class="floatL"&gt; &lt;?php the_author_posts_link(); ?&gt; &amp;nbsp;&lt;/span&gt; &lt;span class="floatL"&gt;&amp;nbsp; - &amp;nbsp;&lt;/span&gt; &lt;span class="floatL"&gt;&lt;?php the_time('F jS, Y'); ?&gt;&lt;/span&gt;&lt;div class="clr"&gt;&lt;/div&gt;&lt;/h3&gt;
                            &lt;p&gt;&lt;?php the_content('Read More') ?&gt;&lt;/p&gt;

$big = 999999999; // need an unlikely integer
&lt;div class="row"&gt;
&lt;div class="pagination"&gt;
echo paginate_links( array(
    'base' =&gt; str_replace( $big, '', esc_url( get_pagenum_link( $big ) ) ),
    'format' =&gt; '?paged=%#%',
    'current' =&gt; max( 1, get_query_var('paged') ),
    'total' =&gt;  $cquery-&gt;max_num_pages
) );
&lt;?php get_footer(); ?&gt;

Please help :)
Thank you,
Harshad Patil