Magento 2 PHTML – How to Call Default Menu

magento2menuphtml

I want to magento default menu in my other phtml file. how to call it?

I didn't found any code for menu please help me.

Thanks

Best Answer

If you want Top Menu in CMS Page then you can use below code in CMS Page.

{{block class="Magento\Theme\Block\Html\Topmenu" template="Magento_Theme::html/topmenu.phtml"}}

But as you mention you want in another Phtml then you can try to put belove code in Phtml.

echo $this->getLayout()->createBlock("Magento\Theme\Block\Html\Topmenu")->setTemplate("Magento_Theme::html/topmenu.phtml")->toHtml();

Hope this will help!