/** * Display 'Out of stock' on category pages */ add_action('woocommerce_before_shop_loop_item_title', 'cc_display_out_of_stock_in_loop'); function cc_display_out_of_stock_in_loop() { global $product; if ( !$product->is_in_stock() ) { echo '' . __('Out of stock', 'woocommerce') . ''; } }