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.

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

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

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!

Happy Coding!

Click to rate this post!
[Total: 3 Average: 5]