Home » Php » php – How to create custom header in magento 2.3.3

php – How to create custom header in magento 2.3.3

Posted by: admin February 25, 2020 Leave a comment

Questions:

I am creating a store in magento 2.3.3.I have created a custom header but its not showing in frontend.
I have done the following steps for creating the custom header;
1: Created a file named customheader.phtml in magento_theme folder inside my theme folder i-e myvendor/mytheme/Magento_Theme/html/customheader.phtml
2: I have added the following code in my dafault.xml file

<referenceContainer name="header.container">
<block class="Magento\Framework\View\Element\Template" name="custom_header" as="custom_header" 
 template="Magento_Theme::html/customheader.phtml" />
    </referenceContainer>
 <move element="minicart" destination="custom_header"/>
    <move element="currency" destination="custom_header"/>
    <move element="logo" destination="custom_header"/>
    <move element="skip_to_content" destination="custom_header"/>
    <move element="header.links" destination="custom_header"/>
    <move element="my-account-link" destination="custom_header" />
    <move element="navigation.sections" destination="custom_header"/>
    <move element="top.search" destination="custom_header" after="navigation.sections"/>
    <move element="top.links" destination="custom_header" />
    <move element="store_language" destination="custom_header" />
    <move element="store_switcher" destination="custom_header" />

After Adding the above code I have executed the following commands;

php bin/magento setup:upgrade && php bin/magento setup:static-content:deploy -f && php bin/magento cache:flush

I have searched the web but no luck. Please help! thanks in advance

How to&Answers: