You are going about this the hard way, and the less efficient way. You already have a Loop on the page. You should be able to use that and that alone.
if (have_posts()) {
while (have_posts()) {
the_post();
if (6 < $wp_query->current_post) {
// formatting for your first six posts
} else {
// formatting for the other posts
}
}
}
That’s it. No new query needed. Pagination will work with no extra effort.
Caveats:
- “Sticky” posts will be included in your first six posts.
- Your post count will be the same for all posts so on page one you
will have six differently formatted posts plus yourposts_per_page
minus 6 other posts. Other pages will just haveposts_per_page
posts.
If you want an extra six on the first (front) page you will need this in your theme’s functions.php
:
function special_offset_pregp_wpse_105496($qry) {
if ($qry->is_main_query()) {
$ppg = get_option('posts_per_page');
$offset = 2;
if (!$qry->is_paged()) {
$qry->set('posts_per_page',$offset);
} else {
$offset = $offset + ( ($qry->query_vars['paged']-1) * $ppg );
$qry->set('posts_per_page',$ppg);
$qry->set('offset',$offset);
add_filter('found_posts', 'special_offset_pregp_fp_wpse_105496', 1, 2 );
}
}
}
add_action('pre_get_posts','special_offset_pregp_wpse_105496');
function special_offset_pregp_fp_wpse_105496($found_posts) {
return $found_posts - 2;
}