Support » Plugin: W3 Total Cache » How to purge specific pages upon Post Publish / Update

  • 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')) {


Viewing 3 replies - 1 through 3 (of 3 total)
  • 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' )
    	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.


    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,

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to purge specific pages upon Post Publish / Update’ is closed to new replies.