Make WordPress Core

Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#34825 closed defect (bug) (fixed)

Impossible to set a default ordering for custom post types (on the admin screen)

Reported by: stephenharris's profile stephenharris Owned by: ocean90's profile ocean90
Milestone: 4.4 Priority: normal
Severity: normal Version: 4.4
Component: Posts, Post Types Keywords: has-patch
Focuses: administration Cc:

Description (last modified by SergeyBiryukov)

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)

34825.patch (701 bytes) - added by stephenharris 9 years ago.
34825-2.patch (510 bytes) - added by stephenharris 9 years ago.
34825.diff (516 bytes) - added by perezlabs 9 years ago.

Download all attachments as: .zip

Change History (16)

@stephenharris
9 years ago

#1 @stephenharris
9 years ago

First patch had accidentally removed the new line from the end of the page.

#2 @johnbillion
9 years ago

  • Keywords has-patch needs-unit-tests needs-testing added
  • Milestone changed from Awaiting Review to 4.4

#3 @SergeyBiryukov
9 years ago

  • Description modified (diff)

#4 @johnbillion
9 years ago

Anyone want to write up some tests for this?

#5 @stephenharris
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 @wonderboymusic
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.

#7 @wonderboymusic
9 years ago

  • Keywords commit removed

This ticket was mentioned in Slack in #core by wonderboymusic. View the logs.


9 years ago

@perezlabs
9 years ago

#9 @perezlabs
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

#11 @ocean90
9 years ago

In 35818:

List Tables: Revert [34728] and [35482].

Part of [34728] was already reverted in [35682], but the default values still made it impossible to set a default ordering for custom post types.

See #25493.
See #34825.

#12 @ocean90
9 years ago

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

In 35819:

List Tables: Revert [34728] and [35482].

Part of [34728] was already reverted in [35682], but the default values still made it impossible to set a default ordering for custom post types.

Merge of [35818] for the 4.4 branch.

See #25493.
Fixes #34825.

This ticket was mentioned in Slack in #core by wonderboymusic. View the logs.


9 years ago

Note: See TracTickets for help on using tickets.