WordPress.org

Ready to get started?Download WordPress

Forums

[Plugin: WP Widget Cache] Hard coded widgets ... how to use widget cache? (5 posts)

  1. houseofstrauss
    Member
    Posted 4 years ago #

    Many of my widgets are called directly from a template tag in the sidebars. Is there any way I can cache these widgets using widget cache, as they don't appear in the widgets admin side.

    Thanks.

    http://wordpress.org/extend/plugins/wp-widget-cache/

  2. Ovidiu
    Member
    Posted 4 years ago #

    I am not sure the author checks the wordpress forums btu I'd be itnerested in this question too :-(

  3. AndrewZhang
    Member
    Posted 4 years ago #

    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>
    }

  4. Rishi
    Member
    Posted 4 years ago #

    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.

  5. AndrewZhang
    Member
    Posted 4 years ago #

    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);
    }

Topic Closed

This topic has been closed to new replies.

About this Topic