Magento 2: How to Call Cms Block in PHTML Template Correctly

Introduction I’m sure you know how to do it. Just paste the following code into the necessary *.phtml template and that’s it: <?php echo $this->getLayout() ->createBlock(\Magento\Cms\Block\Block::class) ->setIdentifier('block_identifier') ->toHtml(); ?> But! Did you know that the \Magento\Cms\Block\Block is depricated since magento 2.4.2 ? So, the solution above is work for Magento 2.4.1 and less. And for Magento 2.4.2 and higher the solution below. Solution If you updated to the newest Magento version (2....

June 3, 2023 · 1 min