Back to Community

How to Control Post Types Order Plugin's Impact on Your Custom Queries

35 threads Sep 10, 2025 PluginPost types order

Content

The Post Types Order plugin is a powerful tool for giving administrators manual control over the display order of posts and custom post types. However, a common challenge arises when you need specific WordPress queries, such as those for filtering, archives, or custom displays, to ignore this custom order and use their own sorting logic (like orderby => 'date', 'title', or 'meta_value').

Based on community discussions, this behavior is not a bug but a fundamental aspect of how the plugin operates. When its "Auto Sort" feature is enabled, it actively modifies WordPress queries to use orderby => 'menu_order', which is essential for the custom order to appear automatically on archive pages and in main loops. The conflict occurs when another part of your site, like a filter, sidebar widget, or custom template, needs to override this global setting.

Why This Happens

The plugin is designed to apply the custom menu order by default to maintain consistency across a site. This global application means it can sometimes override the specific orderby parameters you set in custom WP_Query or query_posts calls, leading to unexpected sorting in certain sections of your website.

Common Solutions

Solution 1: Disable Auto Sort (The Global Approach)

The most straightforward method is to turn off the global automatic sorting. This tells the plugin to stop applying the custom order to every query on the site.

  1. Navigate to Settings > Post Types Order.
  2. Uncheck the "Auto Sort" option and save changes.

After disabling Auto Sort, you must manually specify where you do want the custom order to appear. In those specific queries, add 'orderby' => 'menu_order' to your arguments.

$args = array(
    'post_type' => 'my_cpt',
    'orderby'   => 'menu_order', // Manually apply custom order
    'order'     => 'ASC'
);
$query = new WP_Query( $args );

Solution 2: Use the Ignore Filter (The Targeted Approach)

If you prefer to keep Auto Sort enabled for general site-wide use but need to exclude specific queries, you can use a dedicated filter hook. This is a more precise solution.

Add the following code to your theme's functions.php file or a custom functionality plugin. This example tells the plugin to ignore any query for the standard 'post' post type.

add_filter('pto/posts_orderby/ignore', 'my_theme_ignore_custom_order', 10, 3);
function my_theme_ignore_custom_order($ignore, $orderby, $query) {
    // Get the post_type from the query
    $post_type = isset($query->query_vars['post_type']) ? $query->query_vars['post_type'] : '';
    
    // If the query is for the 'post' post type, ignore custom sorting
    if ( $post_type == 'post' ) {
        $ignore = true;
    }
    
    // For checking multiple post types in an array
    // if ( is_array($post_type) && in_array('post', $post_type) ) {
    //    $ignore = true;
    // }
    
    return $ignore;
}

You can modify the condition (if ( $post_type == 'post' )) to target any specific post type or even other query variables.

Solution 3: Temporarily Remove the Filter (The Quick Fix)

For a one-off scenario where you need to run a single query without custom ordering, you can temporarily disable the plugin's filter, run your query, and then re-enable it.

// Remove the plugin's filter right before your custom query
remove_filter('posts_orderby', 'CPTOrderPosts', 99, 2);

// Run your custom query with its own orderby parameters
$args = array(
    'post_type' => 'my_cpt',
    'orderby'   => 'title', // This will now be respected
    'order'     => 'ASC'
);
$my_query = new WP_Query( $args );

// ... Your loop here ...

// Add the filter back after your query so other loops work normally
add_filter('posts_orderby', 'CPTOrderPosts', 99, 2);

Key Takeaways

  • Auto Sort On: Custom order is applied automatically everywhere. Ideal for sites where most lists should use the manual order.
  • Auto Sort Off: You have full control and must manually add 'orderby' => 'menu_order' to each query where you want the custom order.
  • The pto/posts_orderby/ignore filter provides the best of both worlds, allowing for global automatic sorting with specific, targeted exceptions.

By understanding these different methods, you can harness the power of the Post Types Order plugin for organized content while retaining the flexibility to create dynamic, custom-sorted queries anywhere on your WordPress site.

Related Support Threads Support