hi guys , i created blocks and pages through admin and i selected website to display the content.But i could not see any reflections in frontend. can any one help me ?
Display CMS Static Block In Phtml File:
Here the code to show CMS Static Block in any template (phtml) file in Magento 2,
<?php echo $block->getLayout() ->createBlock('Magento\Cms\Block\Block') ->setBlockId('block_identifier') ->toHtml(); ?>
Display CMS Static Block In CMS Page:
Here the code to show CMS Static Block in any other CMS static page in Magento 2,
{{block class="Magento\Cms\Block\Block" block_id="block_identifier"}}
Display CMS Static Block In XML:
Here the code to show CMS Static Block in any layout (XML) file in Magento 2,
<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>
Hope this helps.
CMS>page, you can directly call by url: Content>pages>find Url key, add this url key directly in site url i.e. example.com/url-key
this is what i given :
{{block class="Magento\\Cms\\Block\\Block" block_id="N_id2-N_block2"}}
{{block class="Magento\Cms\Block\Block" block_id="block_identifier"}}
try this
Content > edit home page > Click on Show/ Hide editor > add content {{block class="Magento\Cms\Block\Block" block_id="test"}} Save. It should work now.