Make WordPress Core

Opened 2 years ago

Closed 4 days ago

#25493 closed defect (bug) (fixed)

Sorting posts in ascending order of date at admin side

Reported by: vinod dalvi Owned by: wonderboymusic
Milestone: 4.4 Priority: normal
Severity: normal Version: 3.1
Component: Posts, Post Types Keywords: has-patch needs-refresh
Focuses: administration Cc:


Posts are displayed in descending order of date in the admin side but if we click on date column header to sort it then again it is sorted in descending order of date instead it should be sorted in ascending order of date.

Attachments (2)

25493.patch (451 bytes) - added by vinod dalvi 2 years ago.
Patch file
25493.diff (725 bytes) - added by wonderboymusic 4 weeks ago.

Download all attachments as: .zip

Change History (9)

@vinod dalvi2 years ago

Patch file

comment:1 @SergeyBiryukov2 years ago

  • Version changed from 3.6.1 to 3.1

Related: [16593]

comment:2 @nacin20 months ago

  • Component changed from Administration to Posts, Post Types
  • Focuses administration added

comment:3 @swissspidy5 weeks ago

  • Keywords commit added; 2nd-opinion needs-testing removed
  • Milestone changed from Awaiting Review to Future Release

Patch still applies and works like a charm:

  1. Posts are still sorted in descending order by default.
  2. Clicking the column changes order to ascending (instead of still being in descending order).

Sounds like a no-brainer to me.

comment:4 @swissspidy5 weeks ago

  • Milestone changed from Future Release to 4.4

@wonderboymusic4 weeks ago

comment:5 @wonderboymusic4 weeks ago

  • Keywords commit removed

Probably needs to be more like 25493.diff, which is still weird - it's not the right solution because it arbitrarily defaults to date. In the previous patch, the CSS classes weren't reflecting the proper state. There is no real holder of the state of the request, so it is hard to parse out what the values of orderby and order are when there is no query string. order gets filled in, orderby does not.

comment:6 @swissspidy4 weeks ago

  • Keywords needs-refresh added

Hmm this also breaks the page list table, as you can see here: https://cloudup.com/cpFvtS3S_7p

It indicates that pages are ordered by date, but in fact they're ordered alphabetically.

comment:7 @wonderboymusic4 days ago

  • Owner set to wonderboymusic
  • Resolution set to fixed
  • Status changed from new to closed

In 34728:

Post List Table: Ensure that edit.php with no query string produces the proper markup and links in the date column header.

Add 2 methods to WP_List_Table, ->get_orderby() and ->get_order(). Override the methods in WP_Posts_List_Table.

WP_Posts_List_Table calls wp_edit_posts_query() in ->prepare_items() which is a wrapper for wp(). As such, we can obtain orderby and order via get_query_var(), instead of the URL.

Fixes #25493.

Note: See TracTickets for help on using tickets.