WordPress get all products

For a custom plugin I want a full list of all products we have in WooCommerce. So, I found this code, but it shows only 10 results, instead of all products.

$loop = new WP_Query( array('post_type' => 'product', 'post_per_page' => -1));

What is the right loop to get all products?

Read more here: WordPress get all products

Leave a Reply

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