Cached tags cloud

Cached tags cloud

Thanks to WordPress transients API, caching almost anything is definitely. The following example shows how to cache the good old tag cloud. Simply paste this code wherever you want you tag cloud to be displayed.

$tag_cloud = get_transient( ‘tag_cloud’ );

if ( false === $tag_cloud   ” === $tag_cloud ){

$args = array(‘echo’ => false);

$tag_cloud = wp_tag_cloud( $args );

set_transient( ‘tag_cloud’, $tag_cloud, 60*60*12 );

}

echo $tag_cloud;