You can add CMS static block content in a template file with your module or theme level.
I hope you have created one static block from the admin panel.
Content -> Elements -> Blocks and create a new CMS static block with your specific content.
Let’s keep the identifier of the static block as, footer_social_links.
Now you have to define your static block using layout, If you want to show CMS content to every page then your layout will be default.xml otherwise it will depend on the content you want to show, and choose a specific layout XML file.
<?xml version="1.0"?> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> <body> <referenceBlock name="footer_links"> <block class="Magento\Cms\Block\Block" name="footer.social.links"> <arguments> <argument name="block_id" xsi:type="string">footer_social_links</argument> </arguments> </block> </referenceBlock> </body> </page>
Now In your template file, you need to call our static block content with the getChildHtml() method.
The first argument is the name of our block defined in the XML file. We have given the block name as a footer. social.links
<?php /** * Call CMS Static block here */ ?> <?= $block->getChildHtml('footer.social.links'); //call CMS static content ?>
Using this simple way, You can give clients flexibility in their content using the admin panel and they can able to change their content periodically if they want to change without the need of a developer.