Development,  Woocommerce,  WordPress

Get woocommerce random products

Sometimes people asks me how to get N random products from Woocommerce plugin. Well, I heard it isn’t obvious or easy. And still I don’t know why. It is more than easy! We just need to use get_posts function.

Simplest function to get N random products (default value is three as you may see in the source code) would look like that:

Leave a Reply

Your email address will not be published. Required fields are marked *