Intuitive Custom Post Order Plugin Not Working — Fix for WP_Query

Intuitive Custom Post Order plugin sorts posts wrong on the front end

The Intuitive Custom Post Order plugin is a convenient way to sort posts by drag and drop in the dashboard. It saves the order in the menu_order field and adds that sorting to queries. But sometimes the order in the dashboard is one and the order on the front end is another.

Problem: The plugin sorts the posts in the dashboard, but a custom WP_Query loop on the site shows them in a different order.

Solution: In my case the cause was one argument of the query. To reduce the load I requested only the post IDs:

<?php
$args = array(
    'post_type'      => 'my_cpt',
    'posts_per_page' => -1,
    'fields'         => 'ids',
);

With this argument the custom order was ignored. After I changed it to full post objects, the bug disappeared:

<?php
$args = array(
    'post_type'      => 'my_cpt',
    'posts_per_page' => -1,
    'fields'         => 'all',
);

If you need only the IDs later, take them from the result:

<?php
$query = new WP_Query( $args );
$ids   = wp_list_pluck( $query->posts, 'ID' );

If it still does not work

  • Check that the post type is enabled in Settings → Intuitive CPO. The plugin sorts only the post types and taxonomies selected there.
  • Do not pass your own orderby. The plugin adds orderby => menu_order only when the query has no order of its own.
  • If you really need an explicit order, set it yourself: 'orderby' => 'menu_order', 'order' => 'ASC'. This works even without the plugin’s query filter.