You can specify either paged
for simple pagination, or offset
if you want to do something special. Calculating the offset yourself is easy: just multiply the current page number (minus two) with the number of posts per page, and add your start offset:
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$posts_per_page = get_option( 'posts_per_page' ),
$additional_loop = new WP_Query( array(
'offset' => ( $paged - 2 ) * $posts_per_page + 5,
) );
I see you use wp_paginate()
, but this function does not know you are using an additional query and will read the global $wp_query
object to get the current page and total number of pages, unless you pass these values yourself:
wp_paginate( array(
'range' => 4,
'anchor' => 2,
'nextpage' => 'Next',
'previouspage' => 'Previous',
'page' => $paged,
'pages' => intval( ceil( $additional_loop->found_posts / $posts_per_page ) ),
) );
This is an additional loop, so there still is a “normal” loop on this page? Watch out that this will not confuse pagination, because WordPress will also try to paginate that loop and return a 404 if it is exhausted – which may be before you reach the last page. Try to do pagination only in the main loop, with the pre_get_posts
hook.