0

Could 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.

Please check with link for live example

<?php get_header(); ?>

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

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

<?php

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

                        </div> 
                        </div> 
<?php
$post->ID;
endwhile;

$big = 999999999; // need an unlikely integer
?>

<div class="row">
<div class="pagination">
<?php
echo paginate_links( array(
    'base' => str_replace( $big, '', esc_url( get_pagenum_link( $big ) ) ),
    'format' => '?paged=%#%',
    'current' => max( 1, get_query_var('paged') ),
    'total' =>  $cquery->max_num_pages
) );
?>
</div>
</div>
<?php get_footer(); ?>
  • Why have you removed your code. I have properly edited it. Please, when you add code in the editor, highlight it and click on the {} sign. this will add your code in a code block – Pieter Goosen Jul 6 '15 at 4:32
  • HoH thank you, i was wondering that i have no rights to add code.. lol – Harshad Jul 6 '15 at 4:42
  • Can you please help me with above script – Harshad Jul 6 '15 at 4:54
  • Thank you very much. A guy VRajesh from Stackexchange have helped me. – Harshad Jul 6 '15 at 5:25
0

here you just need to change on $args array. where you have pas wrong argument.

$args = array (
    'post_type'              => 'post',
    'posts_per_page'         => 3,
    'paged' => $paged
);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.