How To Call CMS Static Block in Magento 2.x

There are three methods to call CMS Static Block, defined step by step below.

Method [1] – How to call CMS Static Block in CMS page

Once created, CMS static Block & need to call in CMS page, The code as below

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

Replace block_identifier ID with your block identifier ID

Method [2] – How to call CMS Static Block in Layout XML file

Once created, CMS static Block & need to call in Layout XML File, The code as below

<referenceContainer name="content">
    <block class="Magento\Cms\Block\Block" name="block_identifier">
        <arguments>
            <argument name="block_id" xsi:type="string">block_identifier</argument>
        </arguments>
    </block>
</referenceContainer>

Replace block_identifier ID with your block identifier ID

Method [3] – How to call CMS Static Block in PHTML file

Once created, CMS static Block & need to call in PHTML File, The code as below

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

Replace block_identifier ID with your block identifier ID

Leave a Reply

Your email address will not be published. Required fields are marked *