I want to set WordPress Transient via Variable Value.
This is an example code with what I'm trying to achieve.
<?php
if ( false === get_transient( 'special_query_results' ) ) {
$ExpiryInterval = "24 * HOUR_IN_SECONDS"; // <--- Storing in Variable
$RandPostQuery = new WP_Query(array('post_type'=>array('tip'),'posts_per_page' => 1,'orderby'=>'rand'));
set_transient( 'special_query_results', $RandPostQuery , $ExpiryInterval ); // <-- Retriving from Variable
}
?>
I don't know why it's not working. If I try setting directly without variable it's working perfectly. Not sure why it's not working this way.