Category Archives: Magento 2

Magento 2: How to Call CMS Static Block in Phtml File

To load static block into phtml file first create a Static block in admin area then past this this code into your phtml file and change your contact-store-info to what ever you is your block name which you created in admin area<getLayout()->createBlock(‘Magento\Cms\Block\Block’)->setBlockId(‘contact-store-info’)->toHtml(); ?>

How to call static block in left sidebar in a page in Magento 2

Do you want to call static block into page or in a phtml page In Magento 2 Follow the instructions bellow  For CMS Pages Use bellow Code {{block class=”Magento\\Cms\\Block\\Block” block_id=”block_identifier”}} If you want to call block into phtml file use this code  Replace block_identifier with your orginal block identifier  <?php echo $block->getLayout()->createBlock(‘Magento\Cms\Block\Block’)->setBlockId(‘block_identifier’)->toHtml();?>