Title: enable cache for shortcode
Last modified: September 28, 2019

---

# enable cache for shortcode

 *  Resolved [vfans](https://wordpress.org/support/users/vfans/)
 * (@vfans)
 * [6 years, 8 months ago](https://wordpress.org/support/topic/enable-cache-for-shortcode/)
 * Hi!
    Is there a way to enable cache function for shortcode ? I tried these following
   code on a page but not working ,the contents of this querry still changed after
   refresh the page. [pissc number=3 orderby=rand cache=3600] [pissc number=3 orderby
   =rand cache=1]
 * or it’s just can’t ?
 * Thanks!

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

 *  Plugin Author [Aldo Latino](https://wordpress.org/support/users/aldolat/)
 * (@aldolat)
 * [6 years, 8 months ago](https://wordpress.org/support/topic/enable-cache-for-shortcode/#post-11978417)
 * Hi,
    the correct shortcode is:
 * `[pissc number=3 orderby="rand" cached=1 widget_id="my_id"]`
 * or, starting from 4.8.4 version (that will be released soon):
 * `[pissc number=3 orderby="rand" cached=1 shortcode_id="my_id"]`
 * Let me know, please.
 *  Thread Starter [vfans](https://wordpress.org/support/users/vfans/)
 * (@vfans)
 * [6 years, 8 months ago](https://wordpress.org/support/topic/enable-cache-for-shortcode/#post-11979189)
 * wow! it worked.
 * I used this shortcode:
    [pissc number=3 orderby=”rand” cached=1 widget_id=”my_id”],
   and the results are cached perfectly even I dont real understand the meaning 
   of [widget_id=”my_id”] is.😅
 * BTW, I think [cached=1] is just a trigger for enable this function, But not a
   timer, Right?
 * so I was wondering how to set a cache-expires-timer for shortcode as same as 
   theme’s widget did?
 * looking forward to version 4.8.4.
 * Thanks a lot.
 *  Plugin Author [Aldo Latino](https://wordpress.org/support/users/aldolat/)
 * (@aldolat)
 * [6 years, 8 months ago](https://wordpress.org/support/topic/enable-cache-for-shortcode/#post-11979371)
 * Hello!
 * > the results are cached perfectly even I dont real understand the meaning of[
   > widget_id=”my_id”] is.
 * This is the ID for that widget. It is mandatory only if you are using more than
   one Posts in Sidebar shortcode in your site, in order to avoid conflicts.
 * The ID is used to uniquely identify a single shortcode. It is useful for two 
   reasons:
    1) store the information for that shortcode in the database; 2) identify
   a shortcode in the rendered page on the front end, so that you can use precise
   CSS styles.
 * When you create a shortcode, use a unique ID for each shortcode.
 * > BTW, I think [cached=1] is just a trigger for enable this function, But not
   > a timer, Right?
 * The timer is defined by another option, `cache_time`:
 * `[pissc number=3 ignore_sticky=1 orderby="rand" cached=1 cache_time=86400]`
 * For a more comprehensive explanation, I updated the wiki of this plugin. See 
   the [cache section](https://github.com/aldolat/posts-in-sidebar/wiki/The-Shortcode#cache)
   for the shortcode.
 * By the way, I just uploaded the new 4.8.4 version to the wild. 🙂
 * Please, let me know!
 *  Thread Starter [vfans](https://wordpress.org/support/users/vfans/)
 * (@vfans)
 * [6 years, 8 months ago](https://wordpress.org/support/topic/enable-cache-for-shortcode/#post-11979875)
 * Brilliant! That’s all I needed.
 * Define a unique shortcode ID truly helpful if I want doing some makeup after 
   then.👍
 * Thank you Aldo!
 *  Plugin Author [Aldo Latino](https://wordpress.org/support/users/aldolat/)
 * (@aldolat)
 * [6 years, 8 months ago](https://wordpress.org/support/topic/enable-cache-for-shortcode/#post-11979937)
 * You are very welcome!
 * As I wrote in my first post, do not use the option `widget_id` but `shortcode_id`.

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

The topic ‘enable cache for shortcode’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/posts-in-sidebar_aed6f1.svg)
 * [Posts in Sidebar](https://wordpress.org/plugins/posts-in-sidebar/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/posts-in-sidebar/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/posts-in-sidebar/)
 * [Active Topics](https://wordpress.org/support/plugin/posts-in-sidebar/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/posts-in-sidebar/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/posts-in-sidebar/reviews/)

 * 5 replies
 * 2 participants
 * Last reply from: [Aldo Latino](https://wordpress.org/support/users/aldolat/)
 * Last activity: [6 years, 8 months ago](https://wordpress.org/support/topic/enable-cache-for-shortcode/#post-11979937)
 * Status: resolved