Skip to content

Instantly share code, notes, and snippets.

View aaroncampbell's full-sized avatar

Aaron D. Campbell aaroncampbell

View GitHub Profile
aaroncampbell /
Created September 5, 2011 19:38 — forked from markjaquith/
TLC Transients — On the fly WordPress transients with soft expiration and one-liner chained syntax.

TLC Transients

A WordPress transients interface with support for soft-expiration (use old content until new content is available), background updating of the transients (without having to wait for a cron job), and a chainable syntax that allows for one liners.


In this simple example, we're defining a feed-fetching callback, and then using tlc_transient with a chain to point to that callback and use it, all in one line. Note that since we haven't used background_only(), the initial load of this will cause the page to pause.