Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2012
667
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.58 KB | None | 0 0
  1. <?php
  2. // page totals
  3. $first_page_total= 9; // total number of posts on first page
  4. $paginated_total = 18; // total number of posts on paginated pages
  5. $posts_to_skip = $paginated_total - $first_page_total;
  6.  
  7. // pagination for custom page(s)
  8. if ( get_query_var('paged') ) { $paged = get_query_var('paged'); }
  9. elseif ( get_query_var('page') ) { $paged = get_query_var('page'); }
  10. else { $paged = 1; }
  11.  
  12. // get the category ID
  13. $idObj1 = get_category_by_slug('updates');
  14. $current_category = $idObj1->term_id;
  15.  
  16. // first page query args
  17. $args1 = array(
  18. 'order' => 'DESC',
  19. 'post_status' => 'publish',
  20. 'cat' => $current_category,
  21. 'paged' => $paged,
  22. 'posts_per_page' => $first_page_total
  23. );
  24.  
  25. if(is_paged()) {
  26. // paginated query args
  27. $offset = (($paged - 1) * $paginated_total)- $posts_to_skip;
  28. $args1['offset'] = $offset;
  29. $args1['posts_per_page'] = $paginated_total;
  30. }
  31.  
  32. $the_query = new WP_Query( $args1 );
  33. $found_posts = $the_query->found_posts;
  34.  
  35. //correct the max number of pages
  36. $pages = 1 + ceil(($found_posts - $first_page_total) / $paginated_total);
  37.  
  38. // add the correct number of pages to the query
  39. $the_query->max_num_pages = $pages;
  40.  
  41. // pagenavi before the the loop
  42. wp_pagenavi(array('query' => $the_query));
  43.  
  44. // Start of the Loop
  45. ?>
  46. <?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
  47. <?php get_template_part( 'content', 'page' ); ?>
  48. <?php endwhile; // end of the loop. ?>
  49.  
  50. <?php
  51. // pagenavi after the loop
  52. wp_pagenavi(array('query' => $the_query));
  53. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement