WP and object persistence (or lack thereof)

PHP is inherently designed as non–persistent language, every request starts from no state and builds up from there.

WP mostly follows this, with every request performing core boot and proceeding to process context from GET/POST request (and possibly user cookie).

The typical mechanisms for persistence in WP are:

  • database (posts / metas / options)
  • object cache (transparently makes Cache API, which by default only lives within page load, to persist)

So effectively if you want something to persist you need to actively take care of storing it via appropriate WP API.