#34825 closed defect (bug) (fixed)
Impossible to set a default ordering for custom post types (on the admin screen)
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 4.4 | Priority: | normal |
Severity: | normal | Version: | 4.4 |
Component: | Posts, Post Types | Keywords: | has-patch |
Focuses: | administration | Cc: |
Description (last modified by )
In the patch for #25493, (specifically [34728]), when an orderby
value is not set in $_GET
it defaults to 'date'. This was corrected for hierarchical post types in [35482] after it was noted that date should not be the default ordering for pages.
However, non-hierarchical custom post types are also having their default ordering set to (publication) 'date', and this may not be the natural ordering (e.g. events).
Previously, you could specify a default ordering by checking $query->get('orderby')
and assigning that property a value if it were empty. That's no longer possible as it will now return 'date', when no orderby has been set.
We should check the actual post type at this line: https://github.com/WordPress/WordPress/blob/fc349932c0d1995603fe3f24953318c4c925390e/wp-admin/includes/post.php#L1011 rather than whether its non-hierarchical and/or provide a means for a post type to determine its own default ordering.
Attachments (3)
Change History (16)
#2
@
9 years ago
- Keywords has-patch needs-unit-tests needs-testing added
- Milestone changed from Awaiting Review to 4.4
#5
@
9 years ago
@johnbillion I'd be happy to, but I don't think this can be covered by (php)unit testing(?). The default value of the query is only being set on the posts screen. It could be tested by something like Behat, but that would be a considerable undertaking.
(Incidentally I'm working on a Behat 'library' for WordPress, in fact an extension of your Behat plug-in, with a view that it could be used for testing core (and plug-ins) alike - but that would be another ticket).
#6
@
9 years ago
- Keywords commit added; needs-unit-tests needs-testing removed
@johnbillion I think this is fine without unit tests, there are a lot of admin pieces that we don't touch.
This ticket was mentioned in Slack in #core by wonderboymusic. View the logs.
9 years ago
#9
@
9 years ago
I added a new patch based on the solution of @stephenharris but from the new repository "develop.svn.wordpress.org" that uses the new directory structure, perhaps it can be useful when making the final commit.
I also tested de patch. Looking good!
This ticket was mentioned in Slack in #core by wonderboymusic. View the logs.
9 years ago
#12
@
9 years ago
- Owner set to ocean90
- Resolution set to fixed
- Status changed from new to closed
In 35819:
First patch had accidentally removed the new line from the end of the page.