• Hi there,
    I’m having an error with your plugin active, in which is overriding the ORDER BY for a custom query I’m doing, even though all the settings indicate it shouldn’t.

    I’ve had to temporarily deactivate your plugin, which solves the issue, but I’d like to fix it instead.

    Am I missing something, or there’s a bug in the plugin? (Latest version)

    Here’s the Query code, that I’m logging:

    error_log( print_r( $search_args, true) );
    
    $sessions_query = new WP_Query();
    $sessions = $sessions_query->query( $search_args );
    
    error_log( $sessions_query->request );

    The search args logged are:

    Array (
        [post_type] => wc_appointment
        [post_status] => Array
            (
                [0] => complete
                [1] => confirmed
                [2] => conflict
                [3] => cancelled
            )
    
        [posts_per_page] => -1
        [post_parent] => 124036
        [orderby] => ID
        [order] => ASC
    )

    However, on the logged request, I got this (note the ORDER BY):

    SELECT   wp_posts.ID
    FROM wp_posts 
    WHERE 1=1  AND wp_posts.post_parent = 124036  AND wp_posts.post_type = 'wc_appointment' AND ((wp_posts.post_status = 'conflict' OR wp_posts.post_status = 'complete' OR wp_posts.post_status = 'confirmed' OR wp_posts.post_status = 'cancelled'))
    ORDER BY wp_posts.menu_order , wp_posts.post_date DESC

    When I disable the plugin, I get (as expected) the following :

    SELECT   wp_posts.ID
    FROM wp_posts 
    WHERE 1=1  AND wp_posts.post_parent = 124036  AND wp_posts.post_type = 'wc_appointment' AND ((wp_posts.post_status = 'conflict' OR wp_posts.post_status = 'complete' OR wp_posts.post_status = 'confirmed' OR wp_posts.post_status = 'cancelled'))
    ORDER BY wp_posts.ID ASC

    The settings for the plugin are:

    • Show / Hide re-order interface : HIDE for that post type (Appointments)
    • Auto Sort : UNCHECKED
    • Admin Sort : CHECKED
    • Archive Drag&Drop : NO for that post type (Appointments)
    • Next / Previous Apply: UNCHECKED

    Thanks

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Bug – Overriding Sort in WP_Query’ is closed to new replies.