I'm developing a Woocommerce shop with both physical and downloadable products. I would like to alter the standard query for the loop to exclude all downloadable products, but I can't figure out a way to do it. I would like these products to only be displayed on a certain archive page, which is no problem to achieve.
I'm doing a few other alterations of the query using pre_get_post, but I can't seem to find an option for downloadable products.
All my products are simple products.
Any help would be greatly appreciated!
Instead of using
pre_get_post
, you could use the dedicatedwoocommerce_product_query
Woocommerce action hook. But as downloadable products are related to a meta query is better to usewoocommerce_product_query_meta_query
Woocommerce dedicated filter hook.It will remove downloadable products from shop page only:
Code goes in function.php file of your active child theme (or theme). Tested and works.