cancel
Showing results for 
Search instead for 
Did you mean: 

How to call .phtml file in magento 2.2?

SOLVED

How to call .phtml file in magento 2.2?

Hello,

I want to call homepost.phtml file in front page,

My file is located in app/code/FishPig/WordPress/view/frontend/templets/sidebar/widget/homepost.phtml.

 

I write code in this file to call 5 recent post. But I don't know how to call this file or display this on front page of my website?

I am trying to call it by below given code but its not display anything

{{block class="FishPig\WordPress\Block\Post" template="FishPig_WordPress::sidebar/homepost.phtml"}}

Please help me.

 

1 ACCEPTED SOLUTION

Accepted Solutions

Re: How to call .phtml file in magento 2.2?

You missed the widget folder inside your template declaration, New path will be 

FishPig_WordPress::sidebar/widget/homepost.phtml

instead of

FishPig_WordPress::sidebar/homepost.phtml

Now final declaration will be,

{{block class="FishPig\WordPress\Block\Post" template="FishPig_WordPress::sidebar/widget/homepost.phtml"}}

Clear cache and check.

 

If Issue Solved, Click Kudos/Accept As solutions. Get Magento insight from
Magento 2 Blogs/Tutorial

View solution in original post

1 REPLY 1

Re: How to call .phtml file in magento 2.2?

You missed the widget folder inside your template declaration, New path will be 

FishPig_WordPress::sidebar/widget/homepost.phtml

instead of

FishPig_WordPress::sidebar/homepost.phtml

Now final declaration will be,

{{block class="FishPig\WordPress\Block\Post" template="FishPig_WordPress::sidebar/widget/homepost.phtml"}}

Clear cache and check.

 

If Issue Solved, Click Kudos/Accept As solutions. Get Magento insight from
Magento 2 Blogs/Tutorial