Plugin Support
qtwrk
(@qtwrk)
I am not sure what do you mean by “determine” in this context
but by default , any and all product , product category pages are cached.
or you mean you want to exclude something from cache ?
yes, products belonging to certain categories
Plugin Support
qtwrk
(@qtwrk)
I am sorry ?
I am not exactly sure what exactly is it you want to do here, please explain a bit
I want a product not to be cached if it belongs to a certain category
I want to exclude products belonging to certain categories from the cache so that they are never cached
I don’t know how to say anymore
Plugin Support
qtwrk
(@qtwrk)
if your product links contains category , like
https://domain.com/my-category/product-1
https://domain.com/my-category/product-2
https://domain.com/my-category/product-3
then you can just exclude by URL my-category in Cache -> Exclude -> Do not cache URL
otherwise you can use this code snippet
add_action( 'template_redirect', 'lscwp_category_no_cache' );
function lscwp_category_no_cache() {
if ( is_product() ) {
global $product;
if ( ! is_a( $product, 'WC_Product' ) ) {
$product = wc_get_product( get_the_ID() );
}
if ( in_array( 12345, $product->get_category_ids() ) ) {
do_action( 'litespeed_control_set_nocache', 'no cache due to category setting' );
}
}
}
where 12345 is the category ID that you want to no-cache
-
This reply was modified 2 years, 2 months ago by
qtwrk.
worked, Thank you my problem solver
You are the best person I have ever met in my entire life