mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-23 09:37:42 +01:00
Add offset support to query_posts(). Props Mark Jaquith. fixes #2558
git-svn-id: http://svn.automattic.com/wordpress/trunk@3867 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
85a6e3ecea
commit
3b2ff8ba4a
@ -75,7 +75,7 @@ class retrospam_mgr {
|
||||
class WP {
|
||||
var $public_query_vars = array('m', 'p', 'posts', 'w', 'cat', 'withcomments', 's', 'search', 'exact', 'sentence', 'debug', 'calendar', 'page', 'paged', 'more', 'tb', 'pb', 'author', 'order', 'orderby', 'year', 'monthnum', 'day', 'hour', 'minute', 'second', 'name', 'category_name', 'feed', 'author_name', 'static', 'pagename', 'page_id', 'error', 'comments_popup', 'attachment', 'attachment_id', 'subpost', 'subpost_id', 'preview', 'robots');
|
||||
|
||||
var $private_query_vars = array('posts_per_page', 'posts_per_archive_page', 'what_to_show', 'showposts', 'nopaging', 'post_type');
|
||||
var $private_query_vars = array('offset', 'posts_per_page', 'posts_per_archive_page', 'what_to_show', 'showposts', 'nopaging', 'post_type');
|
||||
var $extra_query_vars = array();
|
||||
|
||||
var $query_vars;
|
||||
|
@ -874,9 +874,14 @@ class WP_Query {
|
||||
}
|
||||
|
||||
if (($q['what_to_show'] == 'posts')) {
|
||||
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");
|
||||
|
Loading…
Reference in New Issue
Block a user