10

I am searching header.links block to remove one link and add some links but I am not getting where to make changes. Suggest me some solution

  • In this same custom links, how can I add the custom class? – Abrar Pathan Apr 29 at 13:20
  • This does not really answer the question. If you have a different question, you can ask it by clicking Ask Question. You can also add a bounty to draw more attention to this question once you have enough reputation. - From Review – fmsthird Apr 29 at 13:43
  • If you have a new question, please ask it by clicking the Ask Question button. Include a link to this question if it helps provide context. - From Review – Jai Apr 29 at 14:40
18

I Hope this is useful for you,

if you want to remove top.links

Add default.xml file in this path

app/design/frontend/vendor/theme/Magento_Theme/layout/default.xml

        <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
            <body>

                    <referenceBlock name="register-link" remove="true" />           <!--for Create Account Link-->
                    <referenceBlock name="authorization-link" remove="true" />      <!--for Sign In Link  -->
                    <referenceBlock name="wish-list-link" remove="true" />          <!--for WishList Link-->
                    <referenceBlock name="my-account-link" remove="true" />         <!--for My Account Link-->

            </body>
        </page>

if you want to add Custom top links:

go to app/design/frontend/vendor/theme/Magento_Theme/layout/default.xml

        <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
            <body>
            <referenceBlock name="header.links">
                <block class="Magento\Framework\View\Element\Html\Link" name="custom-link">
                <arguments>
                    <argument name="label" xsi:type="string" translate="true">custom link</argument>
                    <argument name="path" xsi:type="string" translate="true">customlink</argument>
                </arguments>
                </block>
            </referenceBlock>

            </body>
        </page>
  • thanks for your answer how to add custom links and change the label of link – zest Sep 28 '16 at 5:05
6

You can add and remove top links by add this line in your in Magento_Theme/layout/default.xml

    <referenceBlock name="header.links">
    <block class="Magento\Framework\View\Element\Html\Link" name="new.link" after="register-link">
        <arguments>
            <argument name="label" xsi:type="string" translate="false">New Link</argument>
            <argument name="path" xsi:type="string" translate="false">newlink</argument>
        </arguments>
    </block>

    <!-- here you can remove whatever link you feel unwanted -->
    <referenceBlock name="register-link" remove="true" />           <!--for Create Account Link-->
    <referenceBlock name="authorization-link" remove="true" />      <!--for Sign In Link  -->
    <referenceBlock name="wish-list-link" remove="true" />          <!--for WishList Link-->
    <referenceBlock name="my-account-link" remove="true" />         <!--for My Account Link-->
    </referenceBlock>
  • 1
    How can I remove compare link in header.links – Omer Jun 5 '17 at 9:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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