How to show categories which are not included in navigation menu in Magento

How to show categories which are not included in navigation menu in Magento

September 17, 2026 · Illustrated author avatarBy Stefan Bogdanescu
How to show categories which are not included in navigation menu in Magento

Displaying Non-Navigation Menu Categories in Magento

In Magento, by default, only categories that are included in the navigation menu are displayed on the storefront. However, you might want to show all available categories, including those not currently part of the navigation menu. To achieve this, you need to modify your category listing template.

Understanding the Current Setup

The navigation menu is controlled by the navigation module. It allows you to set which categories are displayed in the main menu and which are hidden from view on the frontend. By default, only top-level categories that have been configured as “Enabled” in the backend admin are shown.

Showing All Categories Regardless of Menu Status

To display all available categories, regardless of their inclusion in the navigation menu, you need to edit your category listing template file. The specific file depends on your theme:

  • For Magento 2: vendor/magento/theme-frontend-blank/Magento_Theme/templates/html/topmenu/renderer.phtml
  • For other themes: look for a similar file within the appropriate directory

Modifying the Template File

Open the template file and locate the section where categories are being rendered. The code may look something like this:

<?php $_categories = $block->getChildCategories() ?>

This line retrieves only the “enabled” (active) top-level categories that have been included in the navigation menu.

To show all categories, regardless of their status, you need to replace this line with a new query. Here’s an example using an additional block:

<?php $collection = $block->getLayout()->createBlock('Magento\Catalog\Block\Category\Tree')
    ->setCurrentCategory($category)
    ->addActiveFilter() ?>

This code creates a new category tree block and applies an active filter to include all categories, not just those enabled for the navigation menu.

Displaying Recursive Subcategories

For a full recursive display of all sub-categories, you can use the following code within your loop:

<?php $_subcategories = $category->getChildrenCategories() ?>
    <li>
      <a <?php if (count($_subcategories) > 0){ ?>href='#' <?php }else { ?>
      href="<?php echo $_helper->getCategoryUrl($category)?>"    

      <?php }?>>
     <?php echo $category->getName() ?></a>
    </li>

<?php foreach ($_subcategories as $_sub): ?>
  <ul class="level2 nav">
    <?php echo $block->renderCategoryMenuItem($_sub, $currentChildCategory) ?>
  </ul>
<?php endforeach; ?>
</li>

This code retrieves all child categories of the current category and creates a recursive list.

Conclusion

Showing all available categories in Magento requires modifying your theme’s category listing template. By using the appropriate block calls and loops, you can display both top-level and sub-categories regardless of their inclusion in the navigation menu.

Remember to always backup your files before making changes and test thoroughly after implementation. If you’re looking for professional help or want to discuss custom solutions, feel free to reach out to our team at Laravel Company.

The process involves understanding the current setup of category display in Magento, identifying the relevant template file, and modifying it to include all categories through appropriate block calls. The provided code examples demonstrate how to retrieve and display all sub-categories recursively.

This approach ensures that your store displays a comprehensive list of all available product categories, providing a better user experience and potentially driving more targeted traffic to specific products or sections.

Remember to always follow best practices for theme modifications in Magento to ensure compatibility with future updates. If you’re unsure about any aspect of the process, don’t hesitate to consult our team at Laravel Company for expert guidance and support.

In conclusion, displaying all categories in Magento requires a strategic approach to template modification. By understanding the current setup and implementing the appropriate code changes, you can effectively showcase your entire category hierarchy to customers, improving navigation and helping them find products faster.

Magento 2 Catalog Extensions Themes

Our network