Transient is never set. Why?
In one page, I try to set/get two transients. The second works fine. The first doesn't work at all. I can not figure out why.
Here's the relevant code.
$lat = round($toReturn[location][coords][latitude]);
$long = round($toReturn[location][coords][longitude]);
$nearbyLocations = [function that gets nearby locations];
$args = array(
post_type = any,
posts_per_page = -1,
);
$mq[relation] = OR;
foreach($nearbyLocations as $nl) {
$mq[] = array(
'key' = 'location',
'value' = ''.$nl[post_id].'',
'compare' = 'LIKE'
);
}
$args[meta_query] = $mq;
$transient_identifier = nearme_sites_.$lat._.$long;
if ( false === ( $impact_query = get_transient( $transient_identifier ) ) ) {
//This transient is never set
$impact_query = new WP_Query( $args );
set_transient( $transient_identifier, $impact_query, 12 * HOUR_IN_SECONDS );
}
//I do something with the result of $impact_query
$nearbyLocations = [Function that gets nearby locations of a type]
$args = array(
post_type = place,
posts_per_page = -1,
orderby = post_title,
order = ASC,
post__in = array_column($nearbyLocations, 'post_id')
);
$transient_identifier = nearme_place_.$lat._.$long;
if ( false === ( $impact_query = get_transient( $transient_identifier ) ) ) {
//This transient is set, as expected
$impact_query = new WP_Query( $args );
set_transient( $transient_identifier, $impact_query, 24 * HOUR_IN_SECONDS );
}
For a fixed lat/long, the first transient is never set, the second is set as expected.
Any thoughts as to why?
Update: it seems that if I do not include a meta_query in my arguments, the transient does work. So, it's not possible to use a transient when the arguments includes a meta_query?