Opened 16 years ago
Closed 15 years ago
#9819 closed defect (bug) (fixed)
Allow order_by=none in query_posts
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 2.8 | Priority: | normal |
Severity: | normal | Version: | 2.8 |
Component: | Query | Keywords: | has-patch tested commit |
Focuses: | Cc: |
Description
Would like to add an extra orderby value to query_posts, that could return posts based on the order they are in in it's include statement.
So when you do query_posts("include=3,2,5,4,1&orderby=none")
They are return in the order 3,2,5,4,1
Attachments (1)
Change History (15)
#3
@
16 years ago
- Keywords has-patch added
- Version set to 2.8
How about calling it 'orderby=explicit'?
Explicit infers given order, Which brings it to
Don't suppose using 'order=3,2,5,4,1' makes any sense?
Not really.. Since a lot of the time the id's are not known until its queried.
order = false would be sweet. it would optimize the query, too.
False is an option, but empty(false) == true, which means changing the way its currently acting. Thats my reason for a vote for a string.
(This was also discussed on #wordpress-dev beforehand, And i was mentioning things to joostdevalk whilst he was writing this patch)
#5
@
16 years ago
@dd: mmm, looks like you forgot to add the patch...
Please use my full handle..
Sorry... I thought joostdevalk had added the patch.. I'll attach one now.
#9
@
15 years ago
Cannot make this work so that it displays posts in the order of 3,2,5,4,1:
query_posts("include=3,2,5,4,1&orderby=none")
But this filter seems to work:
function filter_orderby($orderby = ) {
$orderby = " FIELD(ID, 3, 2, 5, 4, 1)";
return $orderby;
}
add_filter('posts_orderby', 'filter_orderby');
#10
@
15 years ago
- Resolution fixed deleted
- Status changed from closed to reopened
- Type changed from enhancement to defect (bug)
This does not seem to work in WordPress 3.0.
#11
@
15 years ago
We use this internally in WP and it seems to be working fine. All it means is that ORDER BY will not be in the query.
#12
@
15 years ago
I guess maybe I misunderstood michaelh's original request, then? When use this query
query_posts('include=1,3,2&orderby=none');
I get my posts back as 1,2,3
I actually need to get them back the way I entered it. Does that make sense?
#13
@
15 years ago
I think this may depend on your MySQL version..
But that being said, orderby=none IS ordering by the MySQL Natural ordering right now, which is ordered by insert time (So by ID basically).
#14
@
15 years ago
- Resolution set to fixed
- Status changed from reopened to closed
This is correct. orderby=none does not fulfill the original request here.
However, this ticket has been closed for some time, and there was an enhancement to come out of it.
Adding orderby=provided (or what have you) can take place in a new ticket. If you wish to create one, be sure to reference #9819.
Closing.
Have seen this requested in the forums several times.
How about calling it 'orderby=explicit'?
Don't suppose using 'order=3,2,5,4,1' makes any sense?