Magento 2.1 – How to Move CMS Static Block Widget

magento-2.1magento2static-block

I created a CMS static block called social_media_block through the admin site then created a widget with that block and place it in the page footer. It shows up as the last block in the footer and I would like it to be placed after the newsletter block and before the footer links. I tried the to move the block with

<move element="social_media_block" destination="footer" after="form.subscribe"/>

in app/design/frontend/my/theme/Magento_Theme/layout/default.xml but not moving. Can CMS static block widgets be moved or do I need to create it another way?

Edit:
I tried adding this but got an Invalid block type: Magento\Cms\Block\Widget\Block Exception

<block class="Magento\Cms\Block\Widget\Block " name="social_media_block" before="footer_links"/>

Best Answer

Try this. I'm also not sure you need need to create a widget with that block. Although, I've personally never created a widget. You would need to put the block code within the <referenceContainer name="footer-container">

<block class="Magento\Cms\Block\Block" name="social_media_block" before="footer_links">
  <arguments>
     <argument name="block_id" xsi:type="string">social_media_block</argument>
  </arguments>
</block>

From how I understand it, since that block is something you created and not exactly an out of the box block that comes with Magento, you can't move it. That's just how I interpret it from my understanding.

And the arguments are necessary, else the system won't know what static block to pull.

Also, you can always echo the static block you created in a .phtml file like so:

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

Good for if want to customize the layout of the footer.phtml file or something.