If you are generating a fully custom timeline using our Timeline Express – Post Types Add-On with posts of a specific post status you most likely want to flush the Timeline Express cache each time a post transitions to that status so it appears on the timeline immediately.
For example, if you have a real estate website with a timeline of properties sold and those properties are only shown on the timeline when they are marked as ‘sold’ you’ll want to flush the Timeline Express cache as they transition, so they show up on that timeline immediately.
How To
The code snippet below can be added to your themes functions.php file or into a custom MU plugin, so the cache is flushed when the properties are marked as ‘sold’.
/** * Flush the Timeline Express cache when a property is marked as 'sold'. * * @param string $new_status New post status. * @param string $old_status Old post status. * @param object $post Post object. * * @return null */ function timeline_express_clear_transients_on_property_sold( $new_status, $old_status, $post ) { if ( 'property' !== $post->post_type || 'sold' !== $new_status ) { return; } // Post ID where the Timeline Express timeline exists delete_timeline_express_transients( 1234 ); } add_action( 'transition_post_status', 'timeline_express_clear_transients_on_property_sold', 10, 3 );