How to change post count in wordpress loop?

First, go to Settings->Reading->Blog pages show at most->25. Or change the posts_per_page in main query to 25.

Then, try this code in your template:

if (have_posts()) :
    $count = 0; $paged = ( get_query_var('paged') > 1 ) ? get_query_var('paged') : 1;
    while (have_posts()) : the_post();
        $count++;
        if ($count <= 3 && $paged === 1) :
            if ($count === 1) echo '<div class="break"><h2>Break div | first 3 posts</h2></div>'; ?>
            <div class="first-three">
                <?php the_title() ?>
            </div>
        <?php elseif (3 < $count && $count <= 7 && $paged === 1) :
            if ($count === 4) echo '<div class="break"><h2>Break div | next 4 posts</h2></div>'; ?>
            <div class="next-four">
                <?php the_title() ?>
            </div>
        <?php elseif (7 < $count && $count <= 13 && $paged === 1) :
            if ($count === 8) echo '<div class="break"><h2>Break div | next 6 posts</h2></div>'; ?>
            <div class="next-six">
                <?php the_title() ?>
            </div>
        <?php elseif (13 < $count && $count <= 20 && $paged === 1) :
            if ($count === 14) echo '<div class="break"><h2>Break div | next other 6 posts</h2></div>'; ?>
            <div class="next-other-six">
                <?php the_title() ?>
            </div>
        <?php else :
            if ($count === 21) echo '<div class="break"><h2>Break div | last 6 posts</h2></div>'; ?>
            <div class="last-six">
                <?php the_title() ?>
            </div>
        <?php endif;
    endwhile; ?>
    <div class="nav-previous alignleft"><?php next_posts_link('Older posts'); ?></div>
    <div class="nav-next alignright"><?php previous_posts_link('Newer posts'); ?></div><?php
endif;

Now, you should understand how to do it. Make sure you have at least 25 posts to display and be aware of sticky_post.

Leave a Comment