Add offset support to query_posts(). Props Mark Jaquith. fixes #2558

git-svn-id: https://develop.svn.wordpress.org/trunk@3867 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren
2006-06-13 20:56:38 +00:00
parent 242be34dd6
commit ec11e08a9b
2 changed files with 9 additions and 4 deletions

View File

@@ -874,9 +874,14 @@ class WP_Query {
}
if (($q['what_to_show'] == 'posts')) {
$pgstrt = '';
$pgstrt = (intval($page) -1) * $q['posts_per_page'] . ', ';
$limits = 'LIMIT '.$pgstrt.$q['posts_per_page'];
if ( empty($q['offset']) ) {
$pgstrt = '';
$pgstrt = (intval($page) -1) * $q['posts_per_page'] . ', ';
$limits = 'LIMIT '.$pgstrt.$q['posts_per_page'];
} else { // we're ignoring $page and using 'offset'
$pgstrt = intval($q['offset']) . ', ';
$limits = 'LIMIT ' . $pgstrt . $q['posts_per_page'];
}
} elseif ($q['what_to_show'] == 'days') {
$startrow = $q['posts_per_page'] * (intval($page)-1);
$start_date = $wpdb->get_var("SELECT max(post_date) FROM $wpdb->posts $join WHERE (1=1) $where GROUP BY year(post_date), month(post_date), dayofmonth(post_date) ORDER BY post_date DESC LIMIT $startrow,1");