How to delete a transient on post/page publish?

I am considering it for publication of a new post. Add the below code in your active theme’s functions.php file. function wpse_delete_query_transient( $post ) { // Deletes the transient when a new post is published delete_transient( ‘d_results’ ); } add_action( ‘new_to_publish’, ‘wpse_delete_query_transient’ ); This will delete the transient every time a new post is published. … Read more

How to purge all transient caches?

Not tested, but if you need a quick and dirty way, you could put a script like this in your WordPress folder and call it each time: define( ‘WP_USE_THEMES’, false ); require(‘wp-blog-header.php’); global $wpdb; $wpdb->query( “DELETE FROM $wpdb->options WHERE option_name LIKE ‘%\_transient\_%'” ); Not to be used on a production server.

Integrating WP-TLC-Transients with WordPress – Where to Begin?

Place wherever your code can access Include tlc-transients.php during your plugin/theme load (or otherwise before init hook) Follow examples from readme for library’s API use PS in [still not very common] case you are using Composer you can also just require markjaquith/wp-tlc-transients in composer.json.

WordPress transients for a shortcode

Use this instead of the line in wich you define $days (your second line): $transient = get_transient( ‘your_transient_key’ ); if( !$transient ): $days = file_get_contents( ‘json_file’ ); set_transient( ‘your_transient_key’, $days, DAY_IN_SECONDS*7 ); else: $days = $transient; endif; $days = json_decode( $days ); … May be a bit rough but you get the idea.

Fragment caching increasing database queries

You are using transient API which works storing data on wp_options table by default. That means that additional database queries will be performed to set the transient and to get the transient. With your code the number of queries should be less for non-logged in users in second and subsequent visits when the transient exists … Read more

How to save new transients if query changes?

According to code in OP, the only thing that changes the result is the $tags variable. In this case, the easiste way to do the trick is make the $tags part of the transient name. function get_posts_by_tags($tags){ $transient=”rest-posts-” . md5(serialize($tags)); if(false === ($result = get_transient($transient))) { // the rest of yout function here … if … Read more

Fallback when Transient API fails

Mark Jaquith made a “TLC Transients” method that you might find useful. Essentially, it implements a transient interface that does soft expiration and background updating. https://github.com/markjaquith/WP-TLC-Transients The idea is that you define a function to do the call that gets the data, then define the transient and pass it that function as a callback. When … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)