WordPress.org

Make WordPress Core

Opened 5 years ago

Closed 23 months ago

#14478 closed enhancement (wontfix)

Allow explicit ordering of included posts in query_posts

Reported by: daltonrooney Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Query Keywords:
Focuses: Cc:

Description

This is in reference to ticket #9819

I think it would be useful to add an extra orderby value to query_posts that could return posts based on the order they are listed.

So when you do query_posts("include=3,2,5,4,1&orderby=given")

They should be returned in the order 3,2,5,4,1

As mentioned by @dd32 in the previously referenced ticket, orderby=none returns the posts in MySQL Natural order, which is by ID.

Change History (3)

comment:1 @nacin5 years ago

  • Milestone changed from Awaiting Review to Future Release

comment:2 @dgwyer4 years ago

Would it be better to name this 'orderby=include' to make it clear the source of the sort order is from the 'include' parameter?

So, it would be something like: query_posts("include=3,2,5,4,1&orderby=include")

comment:3 @wonderboymusic23 months ago

  • Milestone Future Release deleted
  • Resolution set to wontfix
  • Status changed from new to closed

you can now order by 'post__in' which does ordering using FIELD

get_posts( array( 'post__in' => array( 1, 2, 3 ), 'orderby' => 'post__in' ) )
Note: See TracTickets for help on using tickets.