Reading list Switch to dark mode

    Call custom block and links in footer in magento 2

    Updated 1 April 2024

    Call custom block and links in footer in magento 2

    In this article we will learn how to call links and custom block in footer in magento 2.

    So, the file which is used to define configurations of footer is default.xml. This file will be located under app/code/Namespace/Module/view/frontend/layout/. This file calls on every page, that’s why we write code for footer in this file.

    Below code is used to call custom links in footer :

    <referenceBlock name="footer_links">
      <block class="Magento\Framework\View\Element\Html\Link" name="custom-link">
        <arguments>
          <argument name="label" xsi:type="string">Custom Link</argument>
          <!-- This will be displayed as the label of the link -->
          <argument name="path" xsi:type="string">path/to/page</argument>
          <!-- here give the path where the link redirect to -->
        </arguments>
      </block>
    </referenceBlock>

    Now If you want to add your own custom block and template inside the footer,
    then below code will be used :

    Searching for an experienced
    Magento 2 Company ?
    Find out More
    <referenceContainer name="footer-container">
      <block class="Magento\Theme\Block\Html\Footer" name="custom_block" as="custom_block" template="Vendor_Module::custom.phtml"/>
    </referenceContainer>

    That’s all in this article, hope it will help you to call custom block and links inside footer. Try the above code and if you have any issue just comment below. 🙂

    . . .

    Leave a Comment

    Your email address will not be published. Required fields are marked*


    Be the first to comment.

    Back to Top

    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home