Last active
August 29, 2015 13:55
-
-
Save raulillana/8731220 to your computer and use it in GitHub Desktop.
WordPress query_posts with custom posts_per_page and pagination
This file contains 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 | |
/** | |
* WordPress query_posts with custom posts_per_page and pagination | |
*/ | |
if( get_query_var('paged') ) $paged = get_query_var('paged'); | |
elseif( get_query_var('page') ) $paged = get_query_var('page'); | |
else $paged = 1; | |
if( !is_paged() ) $offset = ''; | |
elseif( $paged == 2 ) $offset = '&offset=11'; | |
else $offset = '&offset='. (11 *($paged-2)+ 11); | |
$posts = query_posts($query_string .'&orderby=title&order=ASC&posts_per_page=11&paged='. $paged . $offset); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment