How to create a transient that persists the data for the whole duration of the expiration, even when object cache is enabled?

I eventually used a combination of update_option and WP Cron: // Create the option. update_option(‘foo’, ‘bar’, false); /** * Schedule it to be deleted one week from now. * * @param int Expiration timestamp * @param string Hook that will be invoked * @param string Params to send to the hook callback */ wp_schedule_single_event( time() … Read more

Why can’t I save encrypted data in a transient?

So the answer was to use base64_encode and base64_decode. So basically doing something like this to set the transient: $json_contact_info = json_encode( $contact_info ); $transient_data = encrypt_text( $json_contact_info ); $transient_array = base64_encode( $transient_data ); $transient_set = set_transient( $transient_name, $transient_array, 60 * 60 * 24 * 7 ); And then to get the transient: $decrypted_transient_data = … Read more

how to use transient method?

First, you don’t need a raw SQL query, and by using one you give up all of WP’s optimisations. For example, if you run the query twice, it runs twice. If you had used WP_Query to getch those posts though, it would save them the first time to avoid making additional queries. It’s even possible … Read more