• Resolved jakebradley2001

    (@jakebradley2001)


    I would like to have the cache auto purge for all pages if I click save on any page/post. These pages/posts have ACF fields attached to them so I need to have the cache to bust on save. I have used the following code with Siteground cache and works with them but how can I modify it to work with WP-Optimize?

    <?php
    add_action( 'acf/save_post', function( $post_id ) {
    	error_log( 'ACF action triggered' );
    	if ( function_exists( 'sg_cachepress_purge_cache' ) ) {
    		error_log( 'Function exists, clearing cache' );
    		sg_cachepress_purge_cache();
    	} else {
    		error_log( 'Didnt find the function' );
    	}
    });
    
    

Viewing 1 replies (of 1 total)
  • Plugin Contributor Venkat Raj

    (@webulous)

    @jakebradley2001 You could use the following code

    add_action( 'acf/save_post', function( $post_id ) {
    	error_log( 'ACF action triggered' );
    	if ( function_exists( 'WP_Optimize' ) ) {
    		error_log( 'Function exists, clearing cache' );
    		WP_Optimize()->get_page_cache()->purge();
    	} else {
    		error_log( 'Didnt find the function' );
    	}
    });
Viewing 1 replies (of 1 total)
  • The topic ‘Purge Cache on ACF Save Post’ is closed to new replies.