Queries via AJAX don’t keep the same order with exact same parameters

WordPress Event Management, Calendars & Registration Forums General Question Queries via AJAX don’t keep the same order with exact same parameters

This topic contains 2 replies, has 2 voices, and was last updated by  Luis Martins 7 years, 2 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #26048

    Hi,

    Im having a problem where the exact same query retrieves different results depending on wether the query is run via PHP directly or via ajax.

    The following screenshot shows the inspection of variables at run time (ran via PHP directly left and via ajax right:

    https://cl.ly/0H0v283H3p1a

    The query for both cases is:

       $args = array(
           'post_type' => 'event',
           'suppress_filters' => false,
           'event_start_after'=> 'today',
           'event_end_after'=> $start,
           'event_start_before'=> $end,
           'group_events_by'=> 'series',
           'orderby'       => 'eventstart',
           'order'       => 'DESC'
       );
    
       $events = get_posts($args);
    

    The $start and $end variables are passed through and have the values last Monday and this Sunday respectively.

    Any idea why the exact same query would output different results? The direct query returns the events in ASC order of starting date (expected behaviour) but the ajax query results the results in a incorrect order.

    Thank you.

    Luis Martins
    #26057

    Hi Luis,

    I replied to your post here: https://wordpress.org/support/topic/queries-via-ajax-dont-keep-the-same-order-with-exact-same-parameters/

    Are you able to provide the raw SQL queries for both those queries either here or on that thread?

    Stephen Harris
    #26060

    This was in fact a conflict with https://wordpress.org/plugins/intuitive-custom-post-order/
    I had a hard time debugging this one because for some reason QueryMonitor doesn’t work on this site. Thanks for the tip Stephen.

    Luis Martins
Viewing 3 posts - 1 through 3 (of 3 total)
To enable me to focus on Pro customers, only users who have a valid license for the Pro add-on may post new topics or replies in this forum. If you have a valid license, please log-in or register an account using the e-mail address you purchased the license with. If you don't you can purchase one here. Or there's always the WordPress repository forum.