11/22/2017 - 5:19 AM

Call static block in Magento 2

Call static block in page

// If you want to call static block in page
// Try below code :

{{block class="Magento\\Cms\\Block\\Block" block_id="block_identifier"}}



//If you want to call in phtml file :
//Try below code :

echo $block->getLayout()->createBlock('Magento\Cms\Block\Block')->setBlockId('block_identifier')->toHtml();



Your xml file code should be :

<referenceContainer name="sidebar.additional">
   <block class="Magento\Cms\Block\Block" name="yourblockid">
            <argument name="block_id" xsi:type="string">yourblockid</argument>

//At Last if you want to call phtml with your block in cms page :
//Try below code :

{{block class="Magento\Modulename\Block\Blockname" template="Magento_Modulename::templatefilename.phtml"}} 

// Refrence:- https://chetansanghani.wordpress.com/2015/11/20/magento2-display-static-block-in-phtml-file-cms-page/