How to Display a Static Block in PHTML File & CMS Page in Magento 2

In Magento 2, static blocks are a great way to manage reusable content. In this guide, we’ll show you how to easily display a static block within a PHTML file and CMS page

In Phtml File:

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

In CMS Content:

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

In Xml File:

<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>

Leave a Reply

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