Ticket #2558 (closed enhancement: fixed)

Opened 2 years ago

Last modified 2 years ago

query_posts() should support offset

Reported by: markjaquith Assigned to: markjaquith
Priority: normal Milestone: 2.1
Component: General Version: 2.1
Severity: normal Keywords: has-patch 2nd-opinion
Cc:

Description

query_posts() doesn't support "offset," which is hugely annoying. You have to resort to posts_per_page=5&paged=2 to see posts 6-10, for example.

Attachments

query_posts_offset_support.diff (2.0 kB) - added by markjaquith on 06/13/06 10:39:30.
Support for 'offset' when querying posts (/trunk/)

Change History

06/13/06 10:39:30 changed by markjaquith

  • attachment query_posts_offset_support.diff added.

Support for 'offset' when querying posts (/trunk/)

06/13/06 10:43:46 changed by markjaquith

  • status changed from new to assigned.
  • severity changed from normal to enhancement.
  • component changed from Administration to General.
  • owner changed from anonymous to markjaquith.
  • version changed from 2.0.1 to 2.1.
  • keywords set to has-patch 2nd-opinion.

Try this patch out. It adds a new (private) query var: 'offset'

Offset moves the starting post by the specified number of posts.

e.g., 'offset=2' would start with third post (2 posts offset from the first post). This is how it works in Movable Type.

You can use this to specify a range of posts that was not previously possible.

e.g. 'offset=2&posts_per_page=10'

Previously, you would have had to query the first 12 posts and used PHP to ignore the first two. This is much cleaner, more efficient, and easy for people to understand.

06/13/06 20:56:41 changed by ryan

  • status changed from assigned to closed.
  • resolution set to fixed.

(In [3867]) Add offset support to query_posts(). Props Mark Jaquith. fixes #2558