Retrieve posts per customised order through JSON REST API with Advanced Post Types Order

This document describes how to retrieve WordPress posts in a predefined, custom order via the JSON REST API by leveraging the Advanced Post Types Order plugin. The plugin not only allows drag‑and‑drop reordering of posts (and custom post types) in the WordPress admin, but also ensures your custom sort order is applied automatically when fetching content through the REST API.
Prerequisites
- WordPress ≥ 4.7 (for built‑in REST API support)
- Advanced Post Types Order plugin is installed and activated
Define a Custom Order in the Admin
- Navigate to Posts → Post Types Order (or the specific custom post type menu).
- Drag and drop entries to set the desired sequence.
- Click “Update” to save the new order (this action updates the menu_order value for each item).
Verify Custom Order in REST API
By default, the WordPress REST API returns posts ordered by date (orderby=date&order=desc). To apply your custom menu_order, include the standard query parameters:
curl -X GET "https://example.com/wp-json/wp/v2/posts?orderby=menu_order&order=asc"
- orderby=menu_order
- order=asc (or desc, as required)
This instructs the API to sort returned items based on the menu_order field, which correlates directly to the sequence you defined in the admin.
Automatic Integration via Advanced Post Types Order
The Advanced Post Types Order plugin enhances the API behavior:
- Automatic Query Override
When the plugin is active, any REST API call for post ordering will respect your drag‑and‑drop sequence—no additional code is required. Internally, the plugin hooks into the rest_post_query filter, injecting the correct menu_order ordering. - Custom Post Types Support
The plugin supports all public (and many private) post types. To retrieve a custom post type in your predefined order:
curl -X GET "https://example.com/wp-json/wp/v2/{custom_post_type}?orderby=menu_order&order=asc"
- Default Order Override
Optionally, you may enforce custom ordering globally (for all API calls to a given post type) by enabling “Apply order on REST API” in the plugin’s settings panel.
Additional Considerations
- Pagination & Performance
Custom ordering via menu_order scales well, but for extremely large datasets consider combining with indexed meta queries or custom database views. - Search & Filters
You can combine orderby=menu_order with other filters (e.g., categories, tags, author) without interference. - Compatibility
The plugin is compatible with popular caching solutions (e.g., WP Super Cache, W3 Total Cache) and supports both REST API v2 and WPGraphQL through its extensible hooks.
By following the steps above, developers can seamlessly integrate a human‑friendly, drag‑and‑drop ordering interface in WordPress with API‑driven applications, ensuring that content is always presented in the intended sequence.