closed How to call .phtml file in magento 2.2?

+1 vote
asked Jan 30 in Frameworks by Doumeki (480 points)
closed Jan 31 by mithun


I need 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 wrote code in this file to call 5 recent post. But I don't know way to call this file or display this on front page of my website?

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

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

Please help me. Thanks,

closed with the note: Trying for backlinks.

2 Answers

0 votes
answered Jan 30 by mithun (560 points)
Seems like you have missed the widget folder in the path. It should look like
instead of
And the shortcode should read like
{{block class="FishPig\WordPress\Block\Post" template="FishPig_WordPress::sidebar/widget/homepost.phtml"}}
Dont forget to clear cache before checking.
0 votes
answered Jan 30 by Edward121 (240 points)

Those tables are related to MView from Magento 2. It's the indexer that runs in cron every minute by default. MView is used if you set the indexer mode to 'Index by Schedule'.

Magento checks if the _cl tables exist, if not, are created every time the indexer/MView runs. The code related to these table creation is in \Magento\Framework\Mview\View::subscribe().

The insertions in these tables are done by MySQL triggers. All triggers in Magento 2 database are used to update _cl tables: SHOW TRIGGERS. If admin changes the price of the product than it will insert rows in some of the tables. When cron runs after 1 minute, it will trigger indexing on those entities for each involved indexer. After each indexer run, if there are entities affected/cache tags (catalog_product_123), it triggers full page cache/Varnish type cleaning.

_cl tables rows are deleted if are old, like every hour. There is a cron job for this.

// Magento_Indexer/etc/crontab.xml
<job name="indexer_clean_all_changelogs" instance="Magento\Indexer\Cron\ClearChangelog" method="execute">
<schedule>0 * * * *</schedule>

Related questions

0 votes
3 answers 752 views
0 votes
1 answer 379 views
+1 vote
1 answer 261 views
+1 vote
1 answer 211 views
asked Feb 2 in Zend by Edward121 (240 points)
+1 vote
1 answer 352 views
+2 votes
1 answer 121 views
asked Jun 13, 2016 in Magento by Arton