WordPress.org

Make WordPress Core

Changeset 3867


Ignore:
Timestamp:
06/13/06 20:56:38 (8 years ago)
Author:
ryan
Message:

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

Location:
trunk/wp-includes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/classes.php

    r3791 r3867  
    7676    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'); 
    7777 
    78     var $private_query_vars = array('posts_per_page', 'posts_per_archive_page', 'what_to_show', 'showposts', 'nopaging', 'post_type'); 
     78    var $private_query_vars = array('offset', 'posts_per_page', 'posts_per_archive_page', 'what_to_show', 'showposts', 'nopaging', 'post_type'); 
    7979    var $extra_query_vars = array(); 
    8080 
  • trunk/wp-includes/query.php

    r3854 r3867  
    875875 
    876876            if (($q['what_to_show'] == 'posts')) { 
    877                 $pgstrt = ''; 
    878                 $pgstrt = (intval($page) -1) * $q['posts_per_page'] . ', '; 
    879                 $limits = 'LIMIT '.$pgstrt.$q['posts_per_page']; 
     877                if ( empty($q['offset']) ) { 
     878                    $pgstrt = ''; 
     879                    $pgstrt = (intval($page) -1) * $q['posts_per_page'] . ', '; 
     880                    $limits = 'LIMIT '.$pgstrt.$q['posts_per_page']; 
     881                } else { // we're ignoring $page and using 'offset' 
     882                    $pgstrt = intval($q['offset']) . ', '; 
     883                    $limits = 'LIMIT ' . $pgstrt . $q['posts_per_page']; 
     884                } 
    880885            } elseif ($q['what_to_show'] == 'days') { 
    881886                $startrow = $q['posts_per_page'] * (intval($page)-1); 
Note: See TracChangeset for help on using the changeset viewer.