WordPress.org

Support

Support » Plugins and Hacks » [Plugin: WP Widget Cache] Hard coded widgets … how to use widget cache?

[Plugin: WP Widget Cache] Hard coded widgets … how to use widget cache?

Viewing 4 replies - 1 through 4 (of 4 total)
  • I am not sure the author checks the wordpress forums btu I’d be itnerested in this question too 🙁

    Well, I’m not sure what’s the template tag, but I think you can surround the “tag” by some codes yourself,

    while($widget_cache->wcache->save($widget_cache->get_widget_cache_key(<your widget id, make it unique>), <the cache time, like 600, 3600.>, array())
    {
    <here is your widget code>
    }

    I can confirm that this method works.

    I surrounded my code with

    <?php while($widget_cache->wcache->save($widget_cache->get_widget_cache_key("12344321"),9999, array())) { ?>
    
    THE CODE
    
    <?php } ?>

    I was wondering if there was an extra parameter to force this cache to expire whenever a comment gets added or a page gets updated.

    well, you should bind to some actions, like this

    function custom_clearwcache()
    {
    widget_cache_remove(‘<your widget id>’);
    }

    //go http://codex.wordpress.org/Plugin_API/Action_Reference to find your actions
    $custom_action_arr=array(“publish_page”, “comment_post”,”comment_post”,”edit_comment”,”delete_comment”,”wp_set_comment_status”);
    foreach($custom_action_arr as $ca)
    {
    add_action($ca, custom_clearwcache);
    }

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘[Plugin: WP Widget Cache] Hard coded widgets … how to use widget cache?’ is closed to new replies.