Opened 15 years ago
Last modified 5 years ago
#11398 assigned enhancement
new sort method for query_posts (order by last comment date)
Reported by: | erden.ozkan | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 2.9 |
Component: | Query | Keywords: | needs-patch |
Focuses: | Cc: |
Description
I think we need sorting by latest post comment ability for query_posts. "Recent comments" plugins does this but we need this sorting in the core.
BBPress is planned as a WP plugin according latest chat logs posted by Matt. We gonna have to need this anyway.
Attachments (2)
Change History (15)
#2
@
15 years ago
- Keywords needs-patch added; query_posts removed
- Milestone changed from 3.0 to Future Release
#4
follow-up:
↓ 8
@
11 years ago
- Keywords has-patch added; needs-patch gsoc removed
- Milestone changed from Future Release to 3.7
#5
@
11 years ago
updated to LEFT JOIN
, my posts_per_page
was wrong so I didn't notice the limit was off
#7
@
11 years ago
- Keywords commit added
.2.diff has Unit Tests - tests revealed the need for:
$orderby = "ISNULL($wpdb->comments.comment_date), $wpdb->comments.comment_date";
#8
in reply to:
↑ 4
@
11 years ago
Replying to wonderboymusic:
The big issue is that it requires a
JOIN
of posts and comments which won't work if the tables are partitioned or something. This could be an option for the user, but maybe something that core never uses.
WordPress assumes that all blog-level tables are in the same dataset can be joined, including posts, terms, comments, and the associated meta tables. Users is considered a global table, so it cannot be joined with comments, posts, etc. (and is not in core).
Gonna move this into 3.7 for review. It's actually a pretty easy patch. 11398.diff adds
comment_date
as an allowed key fororderby
:$posts = get_posts( array( 'fields' => 'ids', 'orderby' => 'comment_date' ) );
The big issue is that it requires a
JOIN
of posts and comments which won't work if the tables are partitioned or something. This could be an option for the user, but maybe something that core never uses.