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 when a new post is published.
If you want to delete the transients on differrent post status transitions, you may refer codex
Related Posts:
- Get the timout value of a saved transient?
- What is the best way to cache pages and queries in WordPress?
- How to delete a transient on post/page publish?
- Transient not working for custom loops
- Difference between fragment caching and wp_cache
- How to remove duplicate query on page load or make them cacheable
- How many queries are normal to execute on a WP site?
- Why a URL with a query is always slower than that without a query?
- Transient api Caches confused
- How to write update query in WordPress to expire transients
- Is there any way to get all custom posts and all custom terms with it’s meta in few queries?
- How to display SQL query that ran in query?
- How can I create a meta_query with an array as meta_field?
- Query multiple meta key values?
- How to Optimize WP site for millions of posts
- How does object caching work?
- Should I use Transient API to store HTML String, or Object?
- Is get_option() faster than accessing get_transient()?
- Cache remote (HTTP) request with Transients API
- How to get comments by post ID?
- Is there any danger in deleting all transients?
- Differences between wpdb->get_results() and wpdb->query()
- Best practices for using the transients API
- Is there a way of increasing the speed of this query?
- Get all image from single page using this query
- How can I query all users who registered today?
- Get Terms by IDs with IDs order
- Using transients in conjunction with memcached
- Reversing the order of posts AFTER the query is performed
- what are the numbers between curly brackets in search query
- simple sql query on wp_postmeta very slow
- Using WordPress public query variables
- How to Use Wildcards in $wpdb Queries Using $wpdb->get_results & $wpdb->prepare?
- When/why does ‘$query->get( ‘tax_query’ );’ return empty?
- Storing posts social counters by using transient api
- Using a wildcard with delete_transient()
- How to get link and title of next and previous post on single page
- Create pagination and order according to alphabet
- wpdb get posts by taxonomy SQL
- How to List Events by Year and Month Using Advanced Custom Fields?
- Is there any difference between hooks posts_where with posts_join and posts_search performance wise?
- How to organize and cache additional data associated with terms?
- wordpress query – orderby child post date
- How many WordPress SQL Queries per page?
- How to display Section for certain time
- Add multiple value to a query variable in WordPress
- Search custom post type by meta data
- Custom query_var causes displaying posts archive on front page
- Slow wp_enqueue_media()
- Fragment caching increasing database queries
- Multipart/formatted MySQL query problem
- What is the most efficient way of implementing a favorite post system?
- Remove [gallery] shortcode altogether
- Compare two numeric custom fields
- WordPress transients for a shortcode
- wp_dropdown_categories with multiple select
- Advanced Custom Fields – Query Efficiency
- Why does get_the_time(‘F j’) return November 30 for all posts?
- Query by one meta_key and sort by another (possibly NULL value)
- How to tune search argument in WP_Query to show only exactly the same results?
- How to purge all transient caches?
- Custom query filter not working on woocommerce category page
- Duplicate Queries
- Is priming a Transient Cache possible?
- Very slow query
- query multiple taxonomy and show post count
- Search Terms – Querying on either description__like OR name__like in the same Term Query?
- Should the caching of WordPress menus be specific to each page?
- Query & Sort Comments by custom comment meta
- How to get my loop to pull posts into three columns
- How to display lastest post date in the homepage?
- Looping through posts per category gives same posts for each category
- Custom $wpdb Query for Custom Post Type by Category
- Transients vs CRON +Custom Fields: Caching Data Per Post
- Get a user’s most recent post title
- Categories and products in random order
- add_query_arg() XSS Vulnerability
- Count user posts by user ID, Post type and Post status
- Can’t pass table to $wpdb->prepare
- Query set using tax_query with relation ‘OR’ modifies category object?
- $query->query_var[‘post_type’] not set for pages
- is_archive() doesn’t work on public query var archive pages?
- How to extract all ID variables from a query string?
- When add_query_arg() is necessary?
- Different Main Navigation per category
- How to get category link without a database query
- Insert html after certain amount of posts?
- wp remove query
- Show recent products first but “sold out last” in query
- Transient pagination not working properly
- WordPress creating excessive joins on meta_query with search
- How to display liked posts of current user in wordpress?
- Filter query posts by the count of metas for a meta key
- How to tell if $query_var isset?
- Show All Posts Insert Edit Link
- Transient / object cache maximum key length [duplicate]
- $wpdb->get_var not returning a result
- search through post-type attachments titles
- How to count get_users query?
- Date query year and month OR just year