---
title: "Magento 2: Call Custom phtml file on all CMS Pages"
url: "https://magecomp.com/blog/magento-2-call-custom-phtml-file-on-all-cms-pages/"
date: "2021-01-29T16:42:20+00:00"
modified: "2025-02-20T10:03:00+00:00"
author:
  name: "Dhiren Vasoya"
  url: "https://magecomp.com/"
categories:
  - "How To"
  - "Magento 2"
word_count: 250
reading_time: "2 min read"
summary: "Hello Magento Friends,"
description: "To add dynamic content to the CMS pages or CMS blocks we need to call phtml file. Learn more about Magento 2: Call Custom phtml file on all CMS Pages."
keywords: "How To, Magento 2"
language: "en"
schema_type: "Article"
related_posts:
  - title: "How to Create Custom GraphQL in Magento 2?"
    url: "https://magecomp.com/blog/create-custom-graphql-in-magento-2/"
  - title: "Ultimate Guide to Creating an Attractive Checkout Page in Magento 2 Store"
    url: "https://magecomp.com/blog/create-an-attractive-checkout-page-in-magento-2-store/"
  - title: "How to Override Product Shipping Price in Magento 2"
    url: "https://magecomp.com/blog/override-product-shipping-price-magento-2/"
---

# Magento 2: Call Custom phtml file on all CMS Pages

_Published: January 29, 2021_  
_Author: Dhiren Vasoya_  

![Call Custom phtml file On All CMS Pages In M2](https://magecomp.com/blog/wp-content/uploads/2021/01/Call-Custom-phtml-file-On-All-CMS-Pages-In-M2-1024x512.webp)

**Hello Magento Friends,**

Welcome back to our “How To” Magento 2 technical blog series.
With Magento 2 sometimes we need to add dynamic content to our CMS pages. Calling a custom phtml file is a good move. So let us learn about Magento 2: Call Custom phtml file on all CMS Pages.
[![hyva theme development](https://magecomp.com/blog/wp-content/uploads/2025/02/hyva-theme-development-CTA-4.webp)](https://magecomp.com/services/hyva-theme-development/)

## Steps to Call Custom phtml file on all CMS Pages:
**Step 1:** First, you need to create cms_page_view.xml in the following path
**app\code\Vendor\Extension\view\frontend\layout\cms_page_view.xml**

```
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceContainer name="content">
        	<block class="MagentoFrameworkViewElementTemplate" name="custom_phtml_in_cms" template="Vendor_Extension::call_allcms.phtml" />
        </referenceContainer>
    </body>
</page>
```

[![Magento version upgrade](https://magecomp.com/blog/wp-content/uploads/2025/02/Magento-2-Version-Upgrade-CTA-3.webp)](https://magecomp.com/services/magento-upgrade-services/)

**Step 2:** Now you need to add the call_allcms.phtml file in the following path
**app\code\Vendor\Extension\view\frontend\templates\call_allcms.phtml**

```
<?php
	echo "Call this phtml file in all cms pages";
?>
```

That’s it!
## Conclusion:
Following the above steps, you are able to call custom phtml file on all CMS pages of Magento 2. For any doubts or queries, let me know in the comment section and I will be happy to help you. Help your Magento friends by forwarding the article to them. Hit 5 stars if you found the article helpful and stay connected with us!
[![Magento 2 Speed & Performance Optimization Services](https://magecomp.com/blog/wp-content/uploads/2023/10/Magento-2-Speed-Performance-Optimization-Services-CTA-4.webp)](https://magecomp.com/magento-performance-optimization.html)

**Happy Coding!**

</body>


---

_View the original post at: [https://magecomp.com/blog/magento-2-call-custom-phtml-file-on-all-cms-pages/](https://magecomp.com/blog/magento-2-call-custom-phtml-file-on-all-cms-pages/)_  
_Served as markdown by [Third Audience](https://github.com/third-audience) v3.5.3_  
_Generated: 2026-08-26 11:57:49 UTC_  
