I have inherited a theme from Magento's blank theme, now I need to remove the My Account and Wishlist links from the top.links block. To remove the links, I am using Magento_Theme module's default.xml layout file. Below is the xml that I have added to remove the links:

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

But it does not have any effect on frontend. Please tell me if I am missing something? or is it the right place I should place this xml?

I have checked the log files, there is no entry related to layout or top.links.

for me after adding referenceBlock then worked. Tested

   <referenceBlock name="top.links">
        <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>

Here is Reference

  • How you can know what is the name of each block? you need to go to wishlist layout to figure it out or there is more easy solution to find it? – Goldy Sep 14 '16 at 18:14

You can just add my-account-link and register-link inside your themes customer module default.xml file and remove from Magento_Theme default.xml file. Wihslist keep inside default.xml of Magento_Theme folder

app/design/frontend/Package/themename/Magento_Customer/layout/default.xml

XML look like:

 <?xml version="1.0"?>
    <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
        <body>
            <referenceBlock  name="my-account-link" remove="true"/>
            <referenceBlock  name="register-link" remove="true"/>
        </body>
    </page>

Remove var and check.

The login link wasnt remove from the above snippets for me so if anyone is having issues with it too. This snipped worked for me:

<referenceBlock name="top.links">
    <referenceBlock name="register-link" remove="true" />           
    <referenceBlock name="authorization-link" remove="true" />      
    <referenceBlock name="wish-list-link" remove="true" />          
    <referenceBlock name="authorization-link-login" remove="true"/> <!-- This was missing in the above answer, atleast for me -->         
</referenceBlock>

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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