Support » Fixing WordPress » HOWTO: WP-Cache Dynamic Content With Plugins Calls

  • In checking into WP-Cache I noticed that the author said that while it’s possible to keep parts of a page dynamic by using a special HTML comment wrapper around the functions, it’s not possible to call WordPress plugin functions.

    Turns out this isn’t the case. You can in fact call plugin functions in dynamic sections of a cached page. Here’s how:

    // check to see if WP functions are loaded,
    // if not, load the main config file
    // Doing so also lets us call
    // plugin functions
    if (!function_exists(‘the_post’)) {
    // my dynamic content’s plugin function:
    if (function_exists(‘my_plugin_function’)) {

    The part that checks for ‘the_post’ does the work of letting us use plugins: If ‘the_post’ function doesn’t exist then the wp-config.php file is loaded, which in turn loads all the required pieces to run any plugin.

    This is tested exactly as you see it there, and it works.

    Granted, it adds overhead because of loading wp-config.php, which in turns loads many other files, but at least it still lets caching work to reduce load where it can.

    FYI: The same should work with Staticize Reload caching plugin too.

    Have fun.

  • The topic ‘HOWTO: WP-Cache Dynamic Content With Plugins Calls’ is closed to new replies.