I have tried the following URL parameters below, and orderby parameter works fine, displaying all the products sorted by date, but I want only to display the 3 first products (limit parameters doesn't work):
../shop/?orderby=date&limit=3
Anyone had success?
This can be done via a function hooked in
woocommerce_product_queryaction hook.posts_per_pageargument:When setting
3toposts_per_pageargument, it displays 3 products per page (so not convenient).And if we set additionally
nopagingargument to false, all products are displayed without pagination.post__inargument (the right way):This requires to pre-query product IDs sorted by date, with your defined "limit" URL parameter. The first 3 products are displayed without pagination.
The code:
Code goes in functions.php file of your child theme (or in a plugin).
Tested and works with
?orderby=date&limit=3query string (URL variables).