WordPress - refresh the generator cache when a new post is published

If you need the slider to update automatically when you publish a new post, here is a code to help.

Open your the /wp-content/themes/[your-theme]/functions.php file, and add this code:

/*Smart Slider 3 refresh cache start*/

if(class_exists("N2Loader") && class_exists("N2Cache")){
    N2Loader::import("libraries.slider.abstract", "smartslider");

    function refreshCache() {
        $sliderid = 12; //you need your slider ID

    add_action( 'publish_post', 'refreshCache', 10, 0 );
/*Smart Slider 3 refresh cache end*/

Then change the value of the $sliderid to your slider's ID.

You could increase the Cache expiration time to a really large number that will never reached. Do not leave it on 0 as it will make the cache refresh every time someone visits your site!

If you need the cache to be cleared when any of your posts are modified, use 

add_action( 'save_post', 'refreshCache', 10, 0 );

to call the function instead.