Title: ESI // WordPress Function
Last modified: February 21, 2019

---

# ESI // WordPress Function

 *  Resolved [holgee](https://wordpress.org/support/users/holgee/)
 * (@holgee)
 * [7 years, 3 months ago](https://wordpress.org/support/topic/esi-wordpress-function/)
 * Hi,
 * on our homepage, we´ve got a Onlineshop Widget in the header, which counts the
   number of products in the basket. This widget comes out of a function, which 
   is located in seperate .php file and included via the wp functions.php.
 *     ```
       <div class="header-cart"> 
       <?php wpsg_cart_link(); ?>
       <?php wpsg_cart_dropdown(); ?> 
       </div><!-- End .header-cart -->
       ```
   
 * The LS Cache is working perfect on the page, except that we had to exclude all
   pages to get the widget show the correct number of products. So i´m thinking 
   of the ESI function of LightSpeed Cache, to exclude only the widget (or even 
   more the corresponding code) …
 * I´ve already enabled ESI it and try to integrate <esi:inline>, but nothing worked
   properly, or the widget isn´t shown.
 * `<esi:inline name=”/basket” >
    <div class=”header-cart”> </esi:inline> <?php 
   wpsg_cart_link(); ?>
 * Is that the correct usage or i´m on the wrong way regarding the useage of ESI?
   I´m not so familar with the technical integration …
 * Would be very happy, if someone had a suggestion or idea …
 * Many thanks in advance
    <?php wpsg_cart_dropdown(); ?> </div><!– End .header-
   cart –>
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fesi-wordpress-function%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

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

 *  Plugin Support [Hai Zheng⚡](https://wordpress.org/support/users/hailite/)
 * (@hailite)
 * [7 years, 3 months ago](https://wordpress.org/support/topic/esi-wordpress-function/#post-11231730)
 * If that widget can use a shortcode to load the content, things will be easier.
   You can just change that `[xxx]` to `[esi xxx]`, then the magic comes.
 * If not, you need to use our api to make it work.
 * Ref:
    [https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:lscwp:api](https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:lscwp:api)
 * In the bottom there is a `ESI Sample Code` you can try the same way to code.
 * Directly using `<esi` is not recommended in your case.
 *  Thread Starter [holgee](https://wordpress.org/support/users/holgee/)
 * (@holgee)
 * [7 years, 3 months ago](https://wordpress.org/support/topic/esi-wordpress-function/#post-11231950)
 * Hi,
 * BIG thanks for the detailed explanation !!! Unfortunately, the widget can´t use
   a shortcode, unless i would make a widget out of the function (which as well 
   would be possible).
 * But i´ll have a look into this API thing and the sample code first …
 * Once again: many thanks for your help!!!!
 *  Plugin Support [Hai Zheng⚡](https://wordpress.org/support/users/hailite/)
 * (@hailite)
 * [7 years, 3 months ago](https://wordpress.org/support/topic/esi-wordpress-function/#post-11231976)
 * You are most welcome.
 *  Thread Starter [holgee](https://wordpress.org/support/users/holgee/)
 * (@holgee)
 * [7 years, 2 months ago](https://wordpress.org/support/topic/esi-wordpress-function/#post-11295593)
 * Hi,
 * only a short feedback regarding your suggestions:
 * After some try & errors with the ESI API, i´ve made a plugin (or widget) out 
   of the mentioned function. By calling this via `<?php echo do_shortcode( '[esi
   basket-count ttl="0"]' ); ?>` everything worked like it should! It´s possible
   to cache the whole page, except the count of the products in the shop basket 
   in the header.
 * Therefore: many thanks for your help!

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

The topic ‘ESI // WordPress Function’ is closed to new replies.

 * ![](https://ps.w.org/litespeed-cache/assets/icon-256x256.png?rev=2554181)
 * [LiteSpeed Cache](https://wordpress.org/plugins/litespeed-cache/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/litespeed-cache/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/litespeed-cache/)
 * [Active Topics](https://wordpress.org/support/plugin/litespeed-cache/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/litespeed-cache/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/litespeed-cache/reviews/)

 * 4 replies
 * 2 participants
 * Last reply from: [holgee](https://wordpress.org/support/users/holgee/)
 * Last activity: [7 years, 2 months ago](https://wordpress.org/support/topic/esi-wordpress-function/#post-11295593)
 * Status: resolved