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

Props coffee2code.
Fixes #18897.



git-svn-id: https://develop.svn.wordpress.org/trunk@26012 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Scott Taylor 2013-11-05 01:34:44 +00:00
parent 5643e3ca17
commit d8f57f88ad
2 changed files with 5 additions and 8 deletions

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

View File

@ -278,9 +278,6 @@ class Tests_Query_Results extends WP_UnitTestCase {
$this->assertEquals( $expected, wp_list_pluck( $posts, 'post_name' ) );
}
/**
* @ticket 18897
*/
function test_query_offset_and_paged() {
$posts = $this->q->query('paged=2&offset=3');