Title: [Plugin: WP Widget Cache] Hard coded widgets &#8230; how to use widget cache?
Last modified: August 19, 2016

---

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

 *  [houseofstrauss](https://wordpress.org/support/users/houseofstrauss/)
 * (@houseofstrauss)
 * [17 years ago](https://wordpress.org/support/topic/plugin-wp-widget-cache-hard-coded-widgets-how-to-use-widgit-cache/)
 * 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/](http://wordpress.org/extend/plugins/wp-widget-cache/)

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

 *  [Ovidiu](https://wordpress.org/support/users/ovidiu/)
 * (@ovidiu)
 * [17 years ago](https://wordpress.org/support/topic/plugin-wp-widget-cache-hard-coded-widgets-how-to-use-widgit-cache/#post-1085182)
 * I am not sure the author checks the wordpress forums btu I’d be itnerested in
   this question too 🙁
 *  [AndrewZhang](https://wordpress.org/support/users/andrewzhang/)
 * (@andrewzhang)
 * [17 years ago](https://wordpress.org/support/topic/plugin-wp-widget-cache-hard-coded-widgets-how-to-use-widgit-cache/#post-1085183)
 * 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> }
 *  [Rishi](https://wordpress.org/support/users/rishk789/)
 * (@rishk789)
 * [17 years ago](https://wordpress.org/support/topic/plugin-wp-widget-cache-hard-coded-widgets-how-to-use-widgit-cache/#post-1085185)
 * 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.
 *  [AndrewZhang](https://wordpress.org/support/users/andrewzhang/)
 * (@andrewzhang)
 * [17 years ago](https://wordpress.org/support/topic/plugin-wp-widget-cache-hard-coded-widgets-how-to-use-widgit-cache/#post-1085193)
 * 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](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.

 * 4 replies
 * 4 participants
 * Last reply from: [AndrewZhang](https://wordpress.org/support/users/andrewzhang/)
 * Last activity: [17 years ago](https://wordpress.org/support/topic/plugin-wp-widget-cache-hard-coded-widgets-how-to-use-widgit-cache/#post-1085193)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
