{"id":860,"date":"2020-03-04T06:42:47","date_gmt":"2020-03-04T06:42:47","guid":{"rendered":"https:\/\/meetanshi.com\/blog\/2020\/03\/04\/call-phtml-file-in-another-phtml-file-in-magento-2\/"},"modified":"2025-05-22T14:50:46","modified_gmt":"2025-05-22T09:20:46","slug":"call-phtml-file-in-another-phtml-file-in-magento-2","status":"publish","type":"post","link":"https:\/\/meetanshi.com\/blog\/call-phtml-file-in-another-phtml-file-in-magento-2\/","title":{"rendered":"How To Call phtml File In Another phtml File In Magento 2"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Earlier I posted the solution to&nbsp;<a href=\"https:\/\/meetanshi.com\/blog\/call-helper-function-in-phtml-in-magento-2\/\" target=\"_blank\" rel=\"noreferrer noopener\">call helper function in pHTML in Magento 2<\/a>&nbsp;and&nbsp;<a href=\"https:\/\/meetanshi.com\/blog\/call-cms-static-block-in-phtml-file-in-magento-2\/\" target=\"_blank\" rel=\"noreferrer noopener\">call CMS static block in pHTML in Magento 2<\/a>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">However, one of the forum users came up with the requirement to call pHTML file in another pHTML file in Magento 2!<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The developers at Meetanshi tried and tested the below code for the solution to call custom pHTML file in another pHTML file. And here I\u2019m sharing it with my blog readers:<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"method-to-call-phtml-file-in-another-phtml-file-in-magento-2-\">Method to Call phtml file in another phtml file in Magento 2:<\/h2>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;?php echo $this->getLayout()->createBlock(\"Magento\\Framework\\View\\Element\\Template\")->setTemplate(\"Magestore_Webpos::login.phtml\")->toHtml() ?><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">That\u2019s it. You can create a&nbsp;<a href=\"https:\/\/meetanshi.com\/blog\/create-a-custom-tab-and-call-custom-phtml-in-product-ui-component-form-in-magento-2\/\">custom tab and call custom Phtml in product UI component form in Magento 2<\/a>&nbsp;for developing extensions with custom features.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">I\u2019d be grateful if you help me share the solution with the Magento community via social media.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Thank you.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Earlier I posted the solution to&nbsp;call helper function in pHTML in Magento 2&nbsp;and&nbsp;call CMS static block in pHTML in Magento 2. However, one of the&#8230;<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[34],"tags":[],"class_list":["post-860","post","type-post","status-publish","format-standard","hentry","category-magento"],"acf":[],"_links":{"self":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/860","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/comments?post=860"}],"version-history":[{"count":3,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/860\/revisions"}],"predecessor-version":[{"id":15052,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/860\/revisions\/15052"}],"wp:attachment":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/media?parent=860"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/categories?post=860"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/tags?post=860"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}