WordPress transients for a shortcode

Use this instead of the line in wich you define $days (your second line):

$transient = get_transient( 'your_transient_key' );

if( !$transient ):

    $days = file_get_contents( 'json_file' );

    set_transient( 'your_transient_key', $days, DAY_IN_SECONDS*7 );


else:

    $days = $transient;

endif;

$days = json_decode( $days );

... 

May be a bit rough but you get the idea.

Leave a Comment