Title: WP CLI ERRORS &#8211; Call to undefined function add_cacheaction()
Last modified: October 18, 2023

---

# WP CLI ERRORS – Call to undefined function add_cacheaction()

 *  Resolved [tonyleder](https://wordpress.org/support/users/tonyleder/)
 * (@tonyleder)
 * [2 years, 7 months ago](https://wordpress.org/support/topic/wp-cli-errors-call-to-undefined-function-add_cacheaction/)
 * I am creating a plugin for dynamic content. I copy and pasted the original sample
   plugin code and create a plugin called cache-dynamic.
 * [https://github.com/Automattic/wp-super-cache/blob/master/plugins/dynamic-cache-test.php](https://github.com/Automattic/wp-super-cache/blob/master/plugins/dynamic-cache-test.php)
 * When I try to run a wp cli command of any kind I get the error:
 * Fatal error: Uncaught Error: Call to undefined function add_cacheaction() in /
   home/xxxxx/newsletters.xxxxx.com/wp-content/plugins/cache-dynamic/dynamic-cache-
   test.php:25
   Stack trace: 0 /home/xxxxx/newsletters.xxxxxx.com/wp-settings.php(
   462): include_once() 1 /usr/local/wp/php/WP_CLI/Runner.php(1351): require(‘/home/
   xxxx…’) 2 /usr/local/wp/php/WP_CLI/Runner.php(1269): WP_CLI\Runner->load_wordpress()
   3 /usr/local/wp/php/WP_CLI/Bootstrap/LaunchRunner.php(28): WP_CLI\Runner->start()
   4 /usr/local/wp/php/bootstrap.php(83): WP_CLI\Bootstrap\LaunchRunner->process(
   Object(WP_CLI\Bootstrap\BootstrapState)) 5 /usr/local/wp/php/wp-cli.php(32): 
   WP_CLI\bootstrap() 6 /usr/local/wp/php/boot-fs.php(17): require_once(‘/usr/local/
   wp/p…’) 7 {main}
 * thrown in /home/xxxx/newsletters.xxxxx.com/wp-content/plugins/cache-dynamic/dynamic-
   cache-test.php on line 25
   Error: There has been a critical error on this website.
   Learn more about troubleshooting WordPress. There has been a critical error on
   this website.

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

 *  Thread Starter [tonyleder](https://wordpress.org/support/users/tonyleder/)
 * (@tonyleder)
 * [2 years, 7 months ago](https://wordpress.org/support/topic/wp-cli-errors-call-to-undefined-function-add_cacheaction/#post-17133900)
 * Late init and dynamic caching are enabled.
 *  Plugin Author [Donncha O Caoimh (a11n)](https://wordpress.org/support/users/donncha/)
 * (@donncha)
 * [2 years, 7 months ago](https://wordpress.org/support/topic/wp-cli-errors-call-to-undefined-function-add_cacheaction/#post-17134926)
 * add_cacheaction() is in wp-cache-phase2.php, which is loaded by wp-cache-phase1.
   php which is loaded by advanced-cache.php which is loaded by WordPress.
 * That example plugin isn’t a WordPress plugin. It’s a WP Super Cache plugin. It’s
   supposed to be loaded by this plugin, not by WordPress.
 * [https://jetpack.com/support/wp-super-cache/writing-wp-super-cache-plugins/](https://jetpack.com/support/wp-super-cache/writing-wp-super-cache-plugins/)
 *  Thread Starter [tonyleder](https://wordpress.org/support/users/tonyleder/)
 * (@tonyleder)
 * [2 years, 7 months ago](https://wordpress.org/support/topic/wp-cli-errors-call-to-undefined-function-add_cacheaction/#post-17153379)
 * HA! What a goof I am. I read that and then had trouble with the advanced cache
   example 2 but got it partially working as regular plugin. Obviously not a wordpress
   wizard here. It makes perfect sense now and I got example 1 working from the 
   dynamic example.

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

The topic ‘WP CLI ERRORS – Call to undefined function add_cacheaction()’ is closed
to new replies.

 * ![](https://ps.w.org/wp-super-cache/assets/icon-256x256.png?rev=3506220)
 * [WP Super Cache](https://wordpress.org/plugins/wp-super-cache/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-super-cache/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-super-cache/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-super-cache/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-super-cache/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-super-cache/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [tonyleder](https://wordpress.org/support/users/tonyleder/)
 * Last activity: [2 years, 7 months ago](https://wordpress.org/support/topic/wp-cli-errors-call-to-undefined-function-add_cacheaction/#post-17153379)
 * Status: resolved