Please how do i get next set of post to appear on page 2 and not same post appearing on page one

<li>
<?php $paged = (get_query_var('page')) ? get_query_var('page') : 1;
$args = array( 'posts_per_page' => '20','paged' => $paged ); query_posts( $args );
$recent_posts = new WP_Query($args);
while( $recent_posts->have_posts() ) :  
    $recent_posts->the_post() ?> <ul class="rpul">
    <li>    <div class="class="post-thumb wp-post-image" style=' '> <?php if ( has_post_thumbnail() ) : ?>
            <?php the_post_thumbnail('thumbnail') ?>
        <?php endif ?> </div><div class='cat-post-text'>
            <h1> <a href="<?php echo get_permalink() ?>"><?php the_title() ?></a> 
          </h1> 
          </li>
          <hr>
          </ul>
          </li> 
<?php endwhile; ?>
<?php wp_reset_postdata(); # reset post data so that other queries/loops work ?> <?php
    {
    echo '<li class="pagination">', cfct_misc('nav-list'),'</li>';
    echo '</ul>';
}

?>

</div>

What you search for is pagination right?

I am not a WP guy but in general you need to keep track on which page you are and execute a query with a LIMIT and OFFSET clause so that you get what you need from the database, So assume that we have a querystring ?page=2 and that we want to show 25 records per page maximal, then we could write something like this in plain php:

<?php

// retrieve page number. Default is 1,
$page = 1;
if(isset($_GET['page']) && $_GET['page'] > 1) {
    $page = (int) $_GET['page'];
}

// maximum number of records shown on each page (should be somewhere in your configuration)
$max = 25;

// calculate the offset for the query
$offset = ($page -1) * $max; // calculate on which record to start

// build query
$query = "SELECT col1, col2, col3 FROM table LIMIT " . $offset . "," . $max;

// now execute your query and show the records

I hope that it will help you…

thanks but i have managed to use some other code.

Sponsor our Newsletter | Privacy Policy | Terms of Service