Opened 11 years ago
Last modified 6 years ago
#25493 reopened defect (bug)
Sorting posts in ascending order of date at admin side
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 3.1 |
Component: | Posts, Post Types | Keywords: | needs-patch |
Focuses: | administration | Cc: |
Description
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 (4)
Change History (24)
#2
@
11 years ago
- Component changed from Administration to Posts, Post Types
- Focuses administration added
#3
@
9 years 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:
- Posts are still sorted in descending order by default.
- Clicking the column changes order to ascending (instead of still being in descending order).
Sounds like a no-brainer to me.
#5
@
9 years 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.
#6
@
9 years 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.
#7
@
9 years ago
- Owner set to wonderboymusic
- Resolution set to fixed
- Status changed from new to closed
In 34728:
#9
@
9 years ago
@wonderboymusic:
The addition of the get_orderby
and get_order
methods in class-wp-posts-list-table.php
seems to have caused the sorting of custom columns for a custom post type fail when using the filter method, instead of extending the WP_List_Table
class.
In the main class-wp-list-table.php
these methods pull from $_GET
/** * If 'orderby' is set, return it. * * @access protected * @since 4.4.0 * * @return string The value of 'orderby' or empty string. */ protected function get_orderby() { if ( isset( $_GET['orderby'] ) ) { return $_GET['orderby']; } return ''; } /** * If 'order' is 'desc', return it. Else return 'asc'. * * @access protected * @since 4.4.0 * * @return string 'desc' or 'asc'. */ protected function get_order() { if ( isset( $_GET['order'] ) && 'desc' === $_GET['order'] ) { return 'desc'; } return 'asc'; }
However in class-wp-posts-list-table.php
they are relying on the get_query_var()
function, which in order to do a meta query sort, requires setting the orderby
to meta_value
or meta_value_num
.
Am I missing something in this case? Here is a link to the implementation used in the Easy Digital Downloads core:
https://github.com/easydigitaldownloads/Easy-Digital-Downloads/blob/master/includes/admin/downloads/dashboard-columns.php#L115
This ticket was mentioned in Slack in #core by stephenharris. View the logs.
9 years ago
This ticket was mentioned in Slack in #core by ocean90. View the logs.
9 years ago
#16
@
9 years ago
- Keywords revert added; has-patch needs-testing dev-feedback removed
- Resolution fixed deleted
- Status changed from closed to reopened
Patch file