How to make use of Transient API as cookie

In almost all circumstances, a cookie would be preferable to a transient. WP has a really bad habit of not cleaning up transients properly, so unless your code cleans up after itself (Kills useless transients) they will just sit forever in your DB. Even transients that are set to expire sometimes don’t. In terms of … Read more

Transient not behaving as expected

rule of thumb is probably to use transients for simple objects (strings integers, array) as the result of unserialization of objects might be surprising and side effect might happen unless the object is fully static. IIRC, when unserializing an object PHP will also run its default constructor, which in your case will do the query … Read more

is_wp_error() and handling errors

WordPress can be inconsistent as to when is returns a WP_Error object and when it just returns false or string(0) when actually there was an error. I am not sure exactly what feedburner is returning that is not triggering a WP_Error from wp_remote_get() – but if you know wp_remote_get() will return an WP_Error, I would … Read more

Delete transients in website

Transient are not always deleted when they expire, and that makes them unpredictable and sometimes a pain. Whenever I work with transients, I add some kind of functionality to delete the transients when something happens, like I delete transients when publishing posts or updating them if the transient was meant to keep data related to … Read more