Title: Clear cache programatically
Last modified: November 6, 2020

---

# Clear cache programatically

 *  Resolved [ttremain](https://wordpress.org/support/users/ttremain/)
 * (@ttremain)
 * [5 years, 7 months ago](https://wordpress.org/support/topic/clear-cache-programatically/)
 * I found this code that is supposed to clear the cache, either fully, or per postID(
   page)
 * It doesn’t seem to be doing so for me.
 *     ```
       // initilize WordPress environment
       if (!defined('ABSPATH')) {
           require_once('./wp-load.php');
       }
   
       if (has_action('ce_clear_cache')) {
           do_action('ce_clear_cache');
       }
   
       if (has_action('ce_clear_post_cache')) {
           do_action('ce_clear_post_cache', 1111); // post_id
       }
       ```
   
 * Found [here](https://www.keycdn.com/support/wordpress-cache-enabler-plugin)
 * I can confirm that the action does exist, via has_action()

Viewing 1 replies (of 1 total)

 *  Anonymous User 16850768
 * (@anonymized-16850768)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/clear-cache-programatically/#post-13671803)
 * To troubleshoot this further, can you please provide the actual snippet you’re
   attempting to use that is not working in addition to the location where it is
   being fired (e.g. `functions.php` file)?

Viewing 1 replies (of 1 total)

The topic ‘Clear cache programatically’ is closed to new replies.

 * ![](https://ps.w.org/cache-enabler/assets/icon.svg?rev=2442383)
 * [Cache Enabler](https://wordpress.org/plugins/cache-enabler/)
 * [Support Threads](https://wordpress.org/support/plugin/cache-enabler/)
 * [Active Topics](https://wordpress.org/support/plugin/cache-enabler/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/cache-enabler/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/cache-enabler/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: Anonymous User 16850768
 * Last activity: [5 years, 6 months ago](https://wordpress.org/support/topic/clear-cache-programatically/#post-13671803)
 * Status: resolved