Exclude out-of-stock products in category list
-
Hi All,
I’m trying to exclude (not unpublish) out-of-stock products from the products lists on our site. I have the following code in my functions.php file….
function exclude_prods( $wp_query ) { $meta_query = array( array( 'key'=>'_wpsc_stock', 'value'=>'0', 'compare'=>'!=', ), ); $wp_query->set('meta_query',$meta_query); } add_action( 'pre_get_posts', 'exclude_prods' );
The strange thing is, it will work in the single product page, but not the product list, which is what I am trying to exclude from.
Any help will be greatly appreciated, thanks!
Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
- The topic ‘Exclude out-of-stock products in category list’ is closed to new replies.