I am trying to cache the returned data from a query using WP_Query.
It doesn't seem to be storing any where near the time I have specified. Sometimes its refreshing on every page load.
What might I be doing wrong?
<?php
// get our transient data if it exists
// prevents pummelling the database with multiple random queries
$tipsloop = get_transient ('homepage_tipsloop');
if (!$tipsloop )
{
echo 'THIS IS NEW TRANSIENT DATA';
$tipsloop = new WP_Query( array( 'cat' => '8', 'posts_per_page' => '1' , 'orderby' => 'rand') );
set_transient ('homepage_tipsloop' , $tipsloop , MINUTE_IN_SECONDS * 5 ); // cached for 5 minutes
}
?>
<!-- // Tips Loop -->
<?php while ($tipsloop->have_posts()) : $tipsloop->the_post();
echo get_the_post_thumbnail($page->ID, 'homefooter-thumb'); ?>
<div class="home-hotspots-tipscopy">
<?php the_content(); ?>
</div>
<p>
<a href="/category/tips/">MORE TIPS</a>
</p>
<?php endwhile; ?>