I am trying to call a static block in the footer block but it does not work.

I created a theme and then created a default xml:


i then removed the default footer links:

<referenceBlock name="footer_links" remove="true"/>

i then added the code to the block:

<referenceContainer name="footer">
            <block class="Magento\Cms\Block\Block" name="footer_navigation">
                    <argument name="footerNavigation" xsi:type="string">footer_navigation</argument>

I had earlier created the block programmatically using an InstallData.php :

$cmsBlock = $this->blockInterfaceFactory->create();
            ->setContent('{{block class="Topclick\CmsPages\Block\Cmspages" template="Topclick_CmsPages::blockTemplates\footerNavigation.phtml"}}')    
            ->setData('stores', [0]);

so. i am unclear why its not working. i did however test the block and it does indeed render on normal pages using this:

echo $this->getLayout()

Why my xml doesn't work ?

  • <?php echo $this->getLayout()->createBlock('Magento\Cms\Block\Block')->setBlockId('footer_navigation')->toHtml(); ?> doesn't work after clearing cache ? – PЯINCƏ Nov 22 '18 at 13:47
  • First confirm that, your block created or not? – Dhiren Vasoya Nov 22 '18 at 13:53
  • hi @DhirenVasoya-- i did indeed test whether it was created. it is.i rendered your code and it showed up – theSeeker Nov 22 '18 at 13:59

Please try with below code in your \app\design\frontend\MyTheme\Theme-frontend-default\Magento_Theme\layout\default.xml file.

I have called static block id "footer-custom-links". Please change with your static block id.

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    <referenceContainer name="footer-container">  
        <block class="Magento\Cms\Block\Block" name="footercustom-links" as="footercustom-links" after="-">
                <argument name="block_id" xsi:type="string">footer-custom-links</argument>


  • and which one is the name="block_id". is that just a random name? – theSeeker Nov 22 '18 at 17:35
  • No, "block_id" means it will pass "CMS Block ID" as argument. And replace "footer-custom-links" with your actual CMS Static block ID. So, your static block will display in footer section. – Darshan modi Nov 23 '18 at 3:55

Change your xml by following code:

<referenceContainer name="footer">
    <block class="Magento\Cms\Block\Block" name="footer_navigation">
            <argument name="block_id" xsi:type="string">17</argument>
  • hi Sohel. i tried your code but its does not work. do you have any idea how i can go about debugging this. – theSeeker Nov 22 '18 at 14:07
  • This is working fine for me. Did you change your correct block_id, replace 17 to your and clear cache. – Sohel Rana Nov 22 '18 at 14:11
  • Open Magento\Cms\Block\Block, debug inside _toHtml. Don't forget to clear cache. – Sohel Rana Nov 22 '18 at 14:13
  • where would i get that block id from. also where did you get the 17 from? – theSeeker Nov 22 '18 at 14:35
  • When you create static block, you must have id – Sohel Rana Nov 22 '18 at 16:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.