cancel
Showing results for 
Search instead for 
Did you mean: 

Add Custom CMS to Header link

Highlighted

Add Custom CMS to Header link

I am trying to add a button called "social media" to be beside the Storeview switcher.
I tried to follow the answer in: 

https://magento.stackexchange.com/questions/248887/magento-2-add-a-custom-button-to-header-phtml

So I created a CMS block on the backend called 'social media' with id 'social_media'.

I also add the following to the:

app/design/frontend/Smartwave/porto/Smartwave_Porto/layout/default.xml

 file:

 

<referenceBlock name="header.links">
<block class="Magento\Cms\Block\Block" name="social.media" before="-">
<arguments>
<argument name="block_id" xsi:type="string">social_media</argument>
</arguments>
</block>
</referenceBlock>

However, it didn't work.

So my question: what is the right way to add such a button to the header links in magento 2.3.5 ?

2 REPLIES 2
Highlighted

Re: Add Custom CMS to Header link

Hello @achahinewiffa8 

 

It should have worked, Run below commands from your docroot :

php bin/magento setup:static-content:deploy -f
php bin/magento c:f

also add some random text keyword in case anchor is not working.

Let us know if it still doesn't work.

Problem Solved ? Click on 'Kudos' & Accept as Solution to encourage to write more answers !
Highlighted

Re: Add Custom CMS to Header link

In fact, the above code didn't work in my case.

whenever I add the code, a new button called "contact us" shows in the right side of the header.

Knowing that the header already has a contact us button, so in fact I am having 2 contact us button by adding the above code.

While the social media is not showing at all.