Answer the question
In order to leave comments, you need to log in
How to disable caching for Woocomerce random products?
Such a task, it is necessary that the goods that I display through the shortcode are not cached, but constantly take new ones.
I found such a function in the API
protected function get_transient_name() {
$transient_name = 'wc_product_loop_' . md5( wp_json_encode( $this->query_args ) . $this->type );
if ( 'rand' === $this->query_args['orderby'] ) {
// When using rand, we'll cache a number of random queries and pull those to avoid querying rand on each page load.
$rand_index = wp_rand( 0, max( 1, absint( apply_filters( 'woocommerce_product_query_max_rand_cache_count', 5 ) ) ) );
$transient_name .= $rand_index;
}
return $transient_name;
}
[products attribute="stil" terms="Дизайнерский" orderby="rand" limit="8"]
Answer the question
In order to leave comments, you need to log in
Suddenly someone will come in handy, though the decision is not correct, because. will be overwritten during the update, it is necessary to take it out in the function
$rand_index = wp_rand( 0, max );
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question