Respect paged when offset is used in WP_Query. Adds unit tests.

Props coffee2code.
Fixes #18897.


Built from https://develop.svn.wordpress.org/trunk@26012


git-svn-id: http://core.svn.wordpress.org/trunk@25943 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Scott Taylor 2013-11-05 01:35:10 +00:00
parent ba3f75b3c3
commit a519007202

View File

@ -2786,13 +2786,13 @@ class WP_Query {
if ( !$page )
$page = 1;
if ( empty($q['offset']) ) {
$pgstrt = ($page - 1) * $q['posts_per_page'] . ', ';
} else { // we're ignoring $page and using 'offset'
$pgstrt = ($page - 1) * $q['posts_per_page'];
if ( ! empty( $q['offset'] ) ) {
$q['offset'] = absint($q['offset']);
$pgstrt = $q['offset'] . ', ';
$pgstrt += $q['offset'];
}
$limits = 'LIMIT ' . $pgstrt . $q['posts_per_page'];
$limits = 'LIMIT ' . $pgstrt . ', ' . $q['posts_per_page'];
}
// Comments feeds