Empty page last page generated by pagination
-
Hello people,
Recently, I was trying to hide the first 5 posts from the homepage, so I came up with the following code for theloop.php file:
<?php global $post, $query_string, $SMTheme; query_posts($query_string); $i=1; $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; $posts_per_page = 5; $offset = $posts_per_page * ($paged - 1) + 5; $args = array( 'posts_per_page' => $posts_per_page, 'paged' => $paged, 'offset' => $offset, ); if (is_home()||is_front_page()) query_posts($args); if (have_posts()) : if (!isset($_GET['ajaxpage'])) {?> <div class='articles'> <?php } while (have_posts()) : the_post(); ?>
The code works great, except for a strange issue: the pagination generates an extra (last) page with nothing in it, completely empty.
Is it posible to do a workaround of the code to prevent for this last empty page being generated?
Thanks in advance!
Best Regards.
PS: single.php file just does call to theloop.php, so editing single.php won’t help at all. This is the code of the pagination, if needed:
<?php if (is_single()) { ?> <div class="navigation"> <div class="alignleft"> <?php previous_post_link('%link', '← %title', true); ?></div> <div class="alignright"><?php next_post_link('%link', '%title →', true); ?></div> </div> <?php } ?>
Viewing 10 replies - 1 through 10 (of 10 total)
Viewing 10 replies - 1 through 10 (of 10 total)
- The topic ‘Empty page last page generated by pagination’ is closed to new replies.