Created
November 11, 2012 09:54
-
-
Save pa-gerrit/4054333 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // page totals | |
| $first_page_total= 9; // total posts on first page | |
| $paginated_total = 18; // total number of posts on paginated pages | |
| //query args | |
| $idObj1 = get_category_by_slug('updates'); | |
| $catid1 = $idObj1->term_id; | |
| $args1 = array( | |
| 'order' => 'DESC', | |
| 'post_status' => 'publish', | |
| 'cat' => $catid1, | |
| 'paged' => $paged | |
| ); | |
| if(!is_paged()) { | |
| $args1['posts_per_page'] = $first_page_total; | |
| $args2 = array('cat' => $catid1,'offset' => $first_page_total, 'posts_per_page' => $paginated_total); | |
| $fake_query = new WP_Query( $args2 ); | |
| $paginate_query = array('query' => $fake_query); | |
| wp_reset_postdata(); | |
| $the_query = new WP_Query( $args1 ); | |
| } else { | |
| $args1['posts_per_page'] = $paginated_total; | |
| $offset = $first_page_total + ($paginated_total*($paged-2)); | |
| $args1['offset'] = $offset; | |
| $the_query = new WP_Query( $args1 ); | |
| $paginate_query = array('query' => $the_query); | |
| } | |
| $max_num_pages = $paginate_query['query']->max_num_pages; | |
| $found_posts = $paginate_query['query']->found_posts; | |
| if(((($max_num_pages-1)*$paginated_total)+$first_page_total) < $found_posts){ | |
| $paginate_query['query']->max_num_pages = ++$max_num_pages; | |
| } | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment