Opened 17 years ago
Last modified 4 months ago
#11398 assigned enhancement
new sort method for query_posts (order by last comment date)
| Reported by: | erden.ozkan | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | Query | Version: | 2.9 |
| Severity: | normal | Keywords: | has-patch has-unit-tests |
| Cc: | Focuses: |
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 (17)
#4
follow-up:
↓ 8
@
13 years ago
- Keywords has-patch added; needs-patch gsoc removed
- Milestone Future Release → 3.7
#5
@
13 years ago
updated to LEFT JOIN, my posts_per_page was wrong so I didn't notice the limit was off
#7
@
13 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
@
13 years ago
Replying to wonderboymusic:
The big issue is that it requires a
JOINof 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).
#10
@
13 years ago
Ideas via @nacin and @jjj in IRC:
- sort by comment date
- put uncommented posts on the top, on the bottom, or ignore them completely
- uncommented posts should instead be sorted by post_date (possible with a CASE clause)
- sort by "freshest" - which may mean post_modified?
This ticket was mentioned in PR #12344 on WordPress/wordpress-develop by @sukhendu2002.
4 months ago
#15
- Keywords has-patch has-unit-tests added; needs-patch removed
Trac ticket: https://core.trac.wordpress.org/ticket/11398
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Gonna move this into 3.7 for review. It's actually a pretty easy patch. 11398.diff adds
comment_dateas an allowed key fororderby:$posts = get_posts( array( 'fields' => 'ids', 'orderby' => 'comment_date' ) );The big issue is that it requires a
JOINof 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.