Numbered Pagination Showing The Same Posts After Altering WP_Query
I think the title sums the problem up, but I'll explain more with the code below.
As you can see, I'm trying to start the loop from the second latest post for some theme reasons which forced me to alter the main loop, and I used the parameter offset to make that work, and everything worked just fine, but after I moved on with the development, I started developing the numbered pagination, and finally got surprised with my altered loop showing the same posts in every page.
I chose to use WP_Query and not touch query_posts(), as it's simple and faster, now I'm stuck with this problem, and tested everything and didn't work.
Here is the altered loop using class WP_Query:
?php
$paged = get_query_var( 'page' ) ? get_query_var( 'page' ) : 1;
$args = array(
'offset' = 1,
'post_type' = 'post',
'paged' = $paged
);
$offset_loop = new WP_Query( $args );
?
?php if ( $offset_loop-have_posts() ): ?
?php while ( $offset_loop-have_posts() ): $offset_loop-the_post(); ?
div class="blog_loop_container"
article class="blog_post ?php post_class(); ?" id="post-?php the_ID(); ?"
div class="post_thumbnail"?php the_post_thumbnail( 'medium_large' ); ?/div
/article
/div
?php endwhile; ?
?php // wp_reset_postdata(); ?
?php echo thegreatguy_pagination(); ?
?php endif; ?
And here is the pagination function i'm using :
function thegreatguy_pagination() {
global $wp_query; // Calling The Global Variable Representing WP_Query Class.
$totalPages = $wp_query-max_num_pages; // Retrieves The Maximum Pages The Blog has.
$currentPage = max( 1, get_query_var( 'paged' ) ); // Retrieves The Number Of The Current Page.
if ( $totalPages 1 ) { // Check For More Pages To Return.
return paginate_links( array(
'format' = 'page/%#%',
'base' = get_pagenum_link() . '%_%',
'current' = $currentPage,
'prev_text' = 'Previous',
'next_text' = 'Next'
) );
}
}