Magento 2 how to get a block template file phtml

You can simple get a block from template phtml file in Magento 2. There are two examples I will give you here.

If you need to call a template block helloworld.phtml of Magebay_HelloWorld, please use the below code:

<?php 
    echo $this->getLayout()
              ->createBlock('Magento\Catalog\Block\Product\ListProduct')
              ->setTemplate('Magento_Catalog::product/featured.phtml')
              ->setCategoryId(4)
              ->setProductCount(8)
              ->toHtml();
?>

If you need to call template block in CMS static Block or CMS Page in Magento 2, please use the below code:

{{block class="Magento\Catalog\Block\Product\ListProduct" category_id="4" product_count="8" template="Magento_Catalog::product/featured.phtml"}}

Hope it helps. If you have an any ideal about our modules : Magento 2 Multi Vendor Marketplace Extension,Booking System Pro, Online product designer, you can comment under this post. I hope you will build great Magento 2 Extension for your website and Project