admin管理员组文章数量:1316852
I try to save a WP_Query to a transient but it's always comes back false dispite the fact that the transient is saved.
Here is the code:
$fitsToTransientName = 'g_wc_fits_to_' . get_the_ID();
$fitsToTransient = get_transient($fitsToTransientName);
if (false === $fitsToTransient) {
echo "Test";
$argsFits = array(
'post_type' => 'product',
'no_found_rows' => true,
'posts_per_page' => -1,
'meta_query' => array(
array(
'key' => 'accessories',
'value' => '"' . get_the_ID() . '"',
'compare' => 'LIKE'
)
)
);
$fitsToTransient = new WP_Query($argsFits);
set_transient($fitsToTransientName, $fitsToTransient, DAY_IN_SECONDS);
}
$queryFitsTo = $fitsToTransient;
if ($queryFitsTo->have_posts()) { ... // And here goes the loop
Here what I know:
- The line "Test" always echos witch tells me that the $fitsToTransient always is false
- If I var_dump $fitsToTransient it's always just: false
- If I use WP Cli and search for the transient, I can clearly see that it's there and har the full query stored correctly.
- Query Monitor does not tell me that there has been a new transient saved (exept for the first time when it's aqually created).
I've run out of things to try out now and was hoping anyone has any good ideas why it's always "false" and how to fix it.
本文标签: wp querySave large WPQuery to transientfalse
版权声明:本文标题:wp query - Save large WP_Query to transient === false 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742011858a2413032.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论