🔥 Just Launched! Werra Premium Template for HyväSee it in Action

Get The Easiest Way To Call Phtml File In CMS Static Block In Magento 2

By Sanjay JethvaUpdated on May 22, 2025 1 min read

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.

Sanjay Jethva Full Image
Article bySanjay Jethva

Sanjay is the co-founder and CTO of Meetanshi with hands-on expertise with Magento since 2011. He specializes in complex development, integrations, extensions, and customizations. Sanjay is one the top 50 contributor to the Magento community and is recognized by Adobe. His passion for Magento 2 and Shopify solutions has made him a trusted source for businesses seeking to optimize their online stores. He loves sharing technical solutions related to Magento 2 & Shopify.