I am using aloquick
theme in Magento2. Some out of stock products are showing in Featured Products tab of Home Page. I would like to remove those out of stock product from Home Page. My admin panel settings is like below
By making the setting stores>configuration>catalog>inventory> Display Out of Stock Products to 'No' out of products will not visible at frontend. But it seems that in your featured block you have get the collection of product using incorrect code. Use below code which returns only In Stock products collection-
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$productCollectionFactory = $objectManager->create('Magento\Catalog\Model\ResourceModel\Product\CollectionFactory');
$productCollection = $productCollectionFactory->create() ->addAttributeToSelect('*') ->addAttributeToSort('created_at', 'DESC') ->joinField('stock_item', 'cataloginventory_stock_item', 'qty', 'product_id=entity_id', 'is_in_stock=1') ->setPageSize(8)->load();