Save large WP_Query to transient === false


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(
                '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.

Gustav Gesar 3 months 0 Answers 6 views 0

Leave an answer