I already check many answers regarding move header.links to page.top its working but the problem is that its also move my custom links to header content.

that's why I remove greeting message, Sign in, Create an account & add custom links to the top menu, but now I did not found any solution to add sign in, Create an account link & Greeting message into the header-content or near the search box.

I tried by creating default.xml into app/design/.../Magento_Theme/layout, but its not working, I added custom link by module, so please give me solution which can achieve by module.

Here is my default.xml

File Path:


    <referenceBlock name="header.links">

        <!-- Contact us Link -->
        <block class="Magento\Framework\View\Element\Html\Link" name="contactus.link" after="register-link">
                <argument name="label" xsi:type="string" translate="false">Contact Us</argument>
                <argument name="path" xsi:type="string" translate="false">contact-us</argument>

        <!-- CMS Page Link Link -->
        <block class="Magento\Framework\View\Element\Html\Link" name="aboutus.link" after="contactus.link">
                <argument name="label" xsi:type="string" translate="false">About Us</argument>
                <argument name="path" xsi:type="string" translate="false">about-us</argument>

        <!-- CMS Page Link Link -->
        <block class="Magento\Framework\View\Element\Html\Link" name="customerservice.link" after="customerservice.link">
                <argument name="label" xsi:type="string" translate="false">Customer Service</argument>
                <argument name="path" xsi:type="string" translate="false">customer-service</argument>

        <referenceBlock name="register-link" remove="true" />           
        <referenceBlock name="authorization-link-login" remove="true" />      
        <referenceBlock name="wish-list-link" remove="true" />          
        <referenceBlock name="my-account-link" remove="true" />


I also tried add link by using page.top but its shows link below the header-content.


1 Answer 1


Create a block & add a link into phtml file.

add code into default.xml

    <referenceContainer name="header-wrapper">
        <block class="Magento\Framework\View\Element\Template" name="linkboxes"  template="SimpleMagento_HeaderChange::headerlink.phtml" after="header.panel.wrapper"/>

use header-wrapper to get the link between logo & search box.


.dropdown .logout {
    position: static;
    display: inline-block;
    padding-top: 6px;
    float: right;

.dropdown-content {
    display: none;
    position: absolute;
    background-color: #f9f9f9;
    min-width: 160px;
    box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
    padding: 12px 16px;
    z-index: 1000;

.dropdown:hover .dropdown-content {
    display: block;

Use CSS as per your need

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$customerSession = $objectManager->create('Magento\Customer\Model\Session');
$wishlist = $objectManager->create('Magento\Wishlist\Model\Wishlist');
$wishlistObj = $wishlist->loadByCustomerId($customerSession->getCustomerId())->getItemCollection();

if ($wishlistObj) {
$count = $wishlistObj->getSize();

if($customerSession->isLoggedIn()) : ?>
        <div class="dropdown">
            <span><?php echo "Welcome, ".$customerSession->getCustomer()->getName()."! ▼" ?></span>
            <div class="dropdown-content">
                <a class= "header_account_link" href="<?php echo $this->getUrl("customer/account");?>"><?php echo __('My Account')?></a>
                <a class= "header_account_link" href="<?php echo $this->getUrl("wishlist");?>"><?php echo __('My Wish List')." " ?></a><span>(<?= $count ?> items)</span>
                <a class= "header_account_link" href="<?php echo $this->getUrl("customer/account/logout");?>"><?php echo __('Logout')?></a>
<?php else: ?>
        <div class="logout">
            <span class="header_account_link_list login">
                <a class= "header_account_link" href="<?php echo $this->getUrl("customer/account/login");?>"><?php echo __('Sign in')?></a>
            </span> &nbsp; &nbsp;
            <span class="header_account_link_list login">
                <a class= "header_account_link" href="<?php echo $this->getUrl("customer/account/create");?>"><?php echo __('Create an account')?></a>
 <?php endif;?>

<script type="text/x-magento-init">
    "*": {
        "Magento_Ui/js/core/app": {
            "components": {
                "customer": {
                    "component": "Magento_Customer/js/view/customer"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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