0
votes

This is php code for wordpress and this show result of last 15 posts from category which id is cat=7... how to show 10 post after missing first 5 posts.. i need posts 6-15 to display,, any one guide,,

<?php 
        $news = new WP_Query('cat=7&posts_per_page=15');
        if ($news->have_posts() ) :
            $item_number = 0; 
            while ($news->have_posts() ) : $news->the_post(); 
           get_template_part('content'); ?>  
        <?php   endwhile;
       else : ?>
            <p><?php _e( 'Sorry, no posts matched your criteria.' ); ?></p>
        <?php endif;?>
1

1 Answers

3
votes

You need to set the offset parameter in your query. It will be equal to the number of posts you want to skip over. Your WP_Query should look something like :

$news = new WP_Query('cat=7&posts_per_page=15&offset=5');

As a note, this may break pagination.