admin管理员组文章数量:1287488
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?
本文标签: Transient is never set Why
版权声明:本文标题:Transient is never set. Why? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741239015a2363595.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论