WordPress.org

Make WordPress Core

#43591 closed feature request (worksforme)

WordPress REST 2.0 - Media/Post orderby=order

Reported by: spiritofelric Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.9.4
Component: REST API Keywords:
Focuses: rest-api Cc:
PR Number:

Description

Is it possible to update Media requests to orderby the order field in the post table? It looks like it's already indexed for this purpose.

Seems easy to do:
wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php
+881: 'order' => 'post_order',
+ 2163: 'order',

This would be useful for queries such as:
http://wpdistillery.vm/wp-json/wp/v2/media?parent=121&orderby=order

Thanks

Change History (2)

This ticket was mentioned in Slack in #core-restapi by schlessera. View the logs.


21 months ago

#2 @schlessera
21 months ago

  • Milestone Awaiting Review deleted
  • Resolution set to worksforme
  • Status changed from new to closed

The order column for attachments is already usable through the WP REST API, but it is mapped to the argument menu_order, not post_order.

So, this should already work as expected if you query against menu_order instead of post_order.

Note: See TracTickets for help on using tickets.