Earlier I posted the solution to call CMS static block in phtml file in Magento 2.
And today, the below code shows how to call Phtml file in CMS static block in Magento 2.
You can use this method to call the Phtml file on any page.
For example, you want to call an Instagram image on a page in your Magento 2 store.
You can add and control HTML code to be displayed in the frontend using CMS static blocks.
The Magento 2 has the MVC architecture where the Phtml files have the view part of the code while the block classes contain its related logic.
Method to call Phtml file in CMS static block in Magento 2:
{{block class="Magento\Framework\View\Element\Template" template="Vendor_Extension::myfile.phtml"}}
That’s it.
Do share the post with fellow developers via social media.
Thank you.