• Resolved createpop

    (@createpop)


    Hi all,

    I want to exclude the full sidebar from ESI.
    I read the article of “WordPress Shortcodes into ESI Blocks”, however, I don’t find the clue. I know each widget has a ESI setting function, though.
    Any solutions?

    Thank you,

Viewing 12 replies - 1 through 12 (of 12 total)
  • Hi @createpop, you can find the LiteSpeed Cache section on each Apperance > Widgets > Widget box.

    Thread Starter createpop

    (@createpop)

    Hi Stanley,

    Thank you for your comment.
    Yes, I know we can set ESI for each widgets.
    But, I want to exclude the full global sidebar from the cache and want a hole to be punched for the sidebar, if possible.

    Thank you for your support!

    I see, in this situation, you need to modify the theme’s code and convert the dynamic_sidebar into ESI, please follow this article’s instruction.

    Thread Starter createpop

    (@createpop)

    Thank you for your info.
    But, the instruction is not enough for me unfortunately.
    I don’t know how to insert the code into sidebar.php according to the instruction.

    Could you share your sidebar.php content with us? (Please put it on gist or pastiebin) We can provide an example for you.

    Thread Starter createpop

    (@createpop)

    Hi,

    Thank you so much for your support.
    Gist link for sidebar is below.
    https://bit.ly/2tEuvnU

    Thank you!

    1) Please replace row 116 & 122 dynamic_sidebar() function into:

    if ( method_exists( 'LiteSpeed_Cache_API', 'hook_tpl_esi' ) && LiteSpeed_Cache_API::esi_enabled() ) {
    	// This will echo <esi...> script
    	echo LiteSpeed_Cache_API::esi_url( 'litespeed_sidebar_esi', 'Side Bar ESI', array( PUT_SIDEBAR_PARAME_HERE ) ) ;
    } else {
    	// Fall back if ESI not enabled
    	dynamic_sidebar( PUT_SIDEBAR_PARAM_HERE );
    }
    
    (Sidebar param is: $cb_sidebar_id and 'sidebar-global')

    2) Add the following script to your theme’s function.php

    if ( method_exists( 'LiteSpeed_Cache_API', 'hook_tpl_esi' ) && LiteSpeed_Cache_API::esi_enabled() ) {
    	// Hook the esi call back script
    	LiteSpeed_Cache_API::hook_tpl_esi('litespeed_sidebar_esi', 'hook_litespeed_sidebar_esi' );
    
    	function hook_litespeed_sidebar_esi( $param ) {
    		// Print sidebar here with the parameter you put in
    		dynamic_sidebar( $param[ 0 ] );
    		exit;
    	}
    }
    Thread Starter createpop

    (@createpop)

    Thank you for your info.
    I’ll try to do it according to your instruction.
    Unless fitting to my sidebar.php, then I’ll let you know.
    Thank you!

    Thread Starter createpop

    (@createpop)

    Hi,

    Deleting the code from 116 to 122, then insert the above code?
    I tried it, but there is an error.
    Sorry for my lack of knowledge.
    I’d appreciate it if you still support me.

    I’ve commented on your gist with the full code sample, please try on it. For the functions.php code you can keep using the above comment’s one.

    Thread Starter createpop

    (@createpop)

    Hi Stanley,

    I tried and tested you code.
    Everything is fine so far!
    I have done the function what I want.
    I really appreciated your support and effort!!!
    Thank you so much!!

    Your welcome @createpop. Happy to read you solve your issue.

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘How to exclude the sidebar from ESI?’ is closed to new replies.