mercredi 13 juillet 2022

How to disable / increase cache for [products orderby="random"] in Woocommerce

I have the following issue:

Using the shortcode

[products category="" per_page="6" columns="6" orderby="rand" order="desc"]

Generates a couple of sets, which are then repeated on reload instead of truly generating a random set every time. In my understanding, the problem lies in Wordpress caching a number of random queries and pulling those to avoid querying rand on each page load. But that is exactly what I want. I've found out, that this is connected to woocommerce_product_query_max_rand_cache_count hook.

Could you please help me to solve this? How do I work with this hook in functions.php? How to disable this type of cache or at least increase the count? Also, how often is this cache emptied?

Thank you very much in advance.




Aucun commentaire:

Enregistrer un commentaire