Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // page totals
- $first_page_total= 9; // total number of posts on first page
- $paginated_total = 18; // total number of posts on paginated pages
- $posts_to_skip = $paginated_total - $first_page_total;
- // pagination for custom page(s)
- if ( get_query_var('paged') ) { $paged = get_query_var('paged'); }
- elseif ( get_query_var('page') ) { $paged = get_query_var('page'); }
- else { $paged = 1; }
- // get the category ID
- $idObj1 = get_category_by_slug('updates');
- $current_category = $idObj1->term_id;
- // first page query args
- $args1 = array(
- 'order' => 'DESC',
- 'post_status' => 'publish',
- 'cat' => $current_category,
- 'paged' => $paged,
- 'posts_per_page' => $first_page_total
- );
- if(is_paged()) {
- // paginated query args
- $offset = (($paged - 1) * $paginated_total)- $posts_to_skip;
- $args1['offset'] = $offset;
- $args1['posts_per_page'] = $paginated_total;
- }
- $the_query = new WP_Query( $args1 );
- $found_posts = $the_query->found_posts;
- //correct the max number of pages
- $pages = 1 + ceil(($found_posts - $first_page_total) / $paginated_total);
- // add the correct number of pages to the query
- $the_query->max_num_pages = $pages;
- // pagenavi before the the loop
- wp_pagenavi(array('query' => $the_query));
- // Start of the Loop
- ?>
- <?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
- <?php get_template_part( 'content', 'page' ); ?>
- <?php endwhile; // end of the loop. ?>
- <?php
- // pagenavi after the loop
- wp_pagenavi(array('query' => $the_query));
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement