woocommerce_product_query_max_rand_cache_count

woocommerce_product_query_max_rand_cache_count

Appears in: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,
Hook Type: filter

See hook in core

Displaying hooks found in version: woocommerce.9.8.1

apply_filters('woocommerce_product_query_max_rand_cache_count') is found 1 times:

  • /includes/shortcodes/class-wc-shortcode-products.php line 552
    548
    549
    550
    551
    552
    553
    554
    555
    556
    557
        $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;
    }