aaron.lane
Member
Posted 5 months ago #
Hello,
We're using a custom loop to display the 10 most recent posts on a page called News & Events and the 3 most recent posts on our home page (home.php).
How can we implement the following code to purge the cache of our Home and News & Events pages each time a Post is published or updated?
if (function_exists('w3tc_pgcache_flush_post')) {
w3tc_pgcache_flush_post($post_id);
}
Thanks,
Aaron
http://wordpress.org/extend/plugins/w3-total-cache/
ajuliano
Member
Posted 5 months ago #
I would like some help on this issue as well.
I can't get w3tc_pgcache_flush_post($post_id); to work in my code.
add_action( 'publish_lucka', 'run_when_lucka_published', 15 );
function run_when_lucka_published( $post_id ) {
if ( get_post_type( $post_id ) != 'lucka' )
return;
if ( function_exists('w3tc_pgcache_flush_post') ) {
w3tc_pgcache_flush_post( 5864 );
}
}
In the "Page Cache" settings, there should be a "Purge Policy" section that states "Specify the pages and feeds to purge when posts are created, edited, or comments posted."
You should check those boxes that you need purged when you update those items.
aaron.lane
Member
Posted 4 months ago #
Jumbo,
Unfortunately, I am wanting to implement the above code because the pages specified in the "Purge Policy" are not being purged. I suspect is has to do with our Custom Loop.
Can anyone tell us how to use the above function properly?
Thanks in advance,
Aaron