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
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
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