Title: How to call clear cache from function.php
Last modified: August 21, 2016

---

# How to call clear cache from function.php

 *  Resolved [marena](https://wordpress.org/support/users/marena/)
 * (@marena)
 * [12 years ago](https://wordpress.org/support/topic/how-to-call-clear-cache-from-functionphp/)
 * Hi, can someone tell me how to call clear cache from function.php.
 * Now I need to clear cache after editor change something in advanced custom filed
   option page.
 * Here is my code to catche update action:
 * function acf_clear_cache($post_id) {
    if ( $post_id == 0 || $post_id == ‘options’){//
   call clear cache } return $post_id; }
 * add_action(‘acf/save_post’, ‘acf_clear_cache’, 1);
 * Thanks for help.
 * [https://wordpress.org/plugins/quick-cache/](https://wordpress.org/plugins/quick-cache/)

Viewing 6 replies - 1 through 6 (of 6 total)

 *  Plugin Author [Raam Dev](https://wordpress.org/support/users/raamdev/)
 * (@raamdev)
 * [12 years ago](https://wordpress.org/support/topic/how-to-call-clear-cache-from-functionphp/#post-4917353)
 * Hello,
 * You can do it like this:
 *     ```
       add_action( 'save_post', 'my_custom_clear_cache', 10, 1 );
   
       function my_custom_clear_cache( ) {
           $GLOBALS['quick_cache']->clear_cache();
       }
       ```
   
 *  Thread Starter [marena](https://wordpress.org/support/users/marena/)
 * (@marena)
 * [12 years ago](https://wordpress.org/support/topic/how-to-call-clear-cache-from-functionphp/#post-4917364)
 * Thank you very much!
 *  [telepisodesch](https://wordpress.org/support/users/telepisodesch/)
 * (@telepisodesch)
 * [11 years, 12 months ago](https://wordpress.org/support/topic/how-to-call-clear-cache-from-functionphp/#post-4917378)
 * Hi the following code clears all the cache right? how about if I just want to
   clear a cache of a specific page or URL, how will I do that in function.php ?
 *     ```
       add_action( 'save_post', 'my_custom_clear_cache', 10, 1 );
   
       function my_custom_clear_cache( ) {
           $GLOBALS['quick_cache']->clear_cache();
       }
       ```
   
 *  Plugin Author [Raam Dev](https://wordpress.org/support/users/raamdev/)
 * (@raamdev)
 * [11 years, 12 months ago](https://wordpress.org/support/topic/how-to-call-clear-cache-from-functionphp/#post-4917379)
 * You should be able to accomplish that by passing the page or post ID to the `
   auto_purge_post_cache()` function like this:
 *     ```
       add_action( 'save_post', 'my_custom_clear_cache', 10, 1 );
   
       function my_custom_clear_cache( ) {
           $post_id = 123;
           $GLOBALS['quick_cache']->auto_purge_post_cache($post_id);
       }
       ```
   
 *  [telepisodesch](https://wordpress.org/support/users/telepisodesch/)
 * (@telepisodesch)
 * [11 years, 12 months ago](https://wordpress.org/support/topic/how-to-call-clear-cache-from-functionphp/#post-4917380)
 * wow thank you for the reply!
 * another question 🙂
 * how about clearing the cache of the category / archive page and a custom page.
   For example in my site, I created a custom page that lists all posts with recent
   updates on custom fields and content (e.g. mydomain[.]tld/mycustom.php —> which
   I 301 to –> /updates/ (cached via the ?qcAC=1 parameter).
 * Those commands above are clearing the cache immediately?
 *  Plugin Author [Raam Dev](https://wordpress.org/support/users/raamdev/)
 * (@raamdev)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/how-to-call-clear-cache-from-functionphp/#post-4917383)
 * > how about clearing the cache of the category / archive page and a custom page.
 * The custom page would be cleared the same way, by passing the ID of the custom
   page to `auto_purge_post_cache()`. There is no function currently to clear a 
   specific category cache.
 * There is [a feature request](https://github.com/websharks/quick-cache/issues/111)
   open for specifying a list of specific URIs that should be purged when a post
   is published, so after that feature gets implemented there will likely be a function
   you can call to purge a specific URI. You may want to follow that GitHub issue
   for updates.
 * If you have any further questions, please open a new support thread, as this 
   one is already marked as resolved.

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘How to call clear cache from function.php’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/quick-cache_efefef.svg)
 * [Quick Cache (Speed Without Compromise)](https://wordpress.org/plugins/quick-cache/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/quick-cache/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/quick-cache/)
 * [Active Topics](https://wordpress.org/support/plugin/quick-cache/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/quick-cache/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/quick-cache/reviews/)

 * 6 replies
 * 3 participants
 * Last reply from: [Raam Dev](https://wordpress.org/support/users/raamdev/)
 * Last activity: [11 years, 11 months ago](https://wordpress.org/support/topic/how-to-call-clear-cache-from-functionphp/#post-4917383)
 * Status: resolved