Question

How can I add a static block to the top header in Luma theme (see screenprint) ?

enter image description here

Was it helpful?

Solution

app/design/frontend/[Package]/[Theme]/Magento_Theme/layout/default.xml

 <referenceContainer name="header.panel">
    <block class="Magento\Cms\Block\Block" name="header.promotion.message">
        <arguments>
            <argument name="block_id" xsi:type="string">header_promotion_message</argument>
        </arguments>
    </block>
</referenceContainer>

<move element="header.promotion.message" destination="header.panel" before="-"/>

Note: header_promotion_message is your Block Id

enter image description here

Hope this will help you. thanks

OTHER TIPS

Add below code at after top.search referenceContainer:

app/code/design/frontend/[Package]/[Theme]/Magento_Search/layout/default.xml

    <referenceContainer name="header-wrapper">
        <block class="Magento\Cms\Block\Block" name="Promo">
            <arguments>
                <argument name="block_id" xsi:type="string">topPromo</argument>
            </arguments>
        </block>
    </referenceContainer>

Note: Need to change block id topPromo with your block Id and need some CSS for positioning.

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top