Menu order only changes a list when that list’s query sorts by it. These are the ways to ask. The same three choices, as a task, are on Show the saved order on the front end. This page is the contract.
Arguments
Ascending matches the reorder screen: first dragged item first.
$query = array(
'orderby' => 'menu_order',
'order' => 'ASC',
'post_status' => 'publish',
'post_type' => 'post',
'posts_per_page' => 50,
);
$posts = get_posts( $query );
orderby can be menu_order title if you want a stable tiebreaker. The reorder screen uses that. A public query that only sets menu_order is fine when the numbers are unique, which they are after a drag, because the plugin renumbers siblings.
Query Loop
| Control | What it does |
|---|---|
| Custom Order | Sets the block’s order to menu order, ascending. Hidden when the loop inherits the template query |
| Sort by field | Sorts by one public custom field instead. Numeric fields sort as numbers. Text fields sort A to Z. Choosing a field turns Custom Order off |
A field shows up there when it is registered for that post type, exposed to the REST API, stored as a single value, and its type is string, number, or integer. Keys that start with an underscore stay hidden. Posts missing that field are still included.
Advanced rewrite
When a type’s Advanced sort is Menu Order, two hooks do the work. posts_orderby replaces the SQL sort on normal front-end queries. pre_get_posts does the same for get_posts(), which suppresses filters and would otherwise skip the SQL hook. Both bail in the admin and on feeds. Both bail when the query names more than one post type. The SQL hook also treats the blog home as the post type.
The replacement is the whole sort, not an extra key. Date, title, and a Query Loop’s Custom Order all lose to it while it is on. The direction is the Advanced sort order, ASC or DESC. Filters can turn the rewrite off globally or per type. See Hooks.
What still will not follow
- Sticky posts on the blog. Set
ignore_sticky_postsor unstick them - Term archives. The query is “posts in this category,” and this plugin does not attach an order to the term
- Navigation menus built in Appearance → Menus
- Another callback on
posts_orderbyorpre_get_poststhat runs after priority 30
