I am using Porto Theme (Magento 2) for building an e-commerce website. I have some categories that has sub-categories, so when I go to that sub-categories page, then it is showing the category filter empty, so I want to remove the category filter only (not price filter) only where further sub-categories are not there. For example: https://www.ekaani.com/brands/ekaani-gods.html

I have tried to remove that, but when I try to edit category_view.xml page, then the whole sidebar disappears. What I have tried is that adding remove=true in the last block.

<?xml version="1.0"?>
 * Copyright © 2018 Porto. All rights reserved.
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="2columns-left" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
        <referenceContainer name="page.top">
             <block class="Magento\Catalog\Block\Category\View" name="category_banner" template="category/banner.phtml" ifconfig="porto_settings/category/category_description" before="-"/>
        <referenceContainer name="content">
            <block class="Magento\Catalog\Block\Category\View" name="category_desc_main_column" template="category/desc_main_column.phtml" ifconfig="porto_settings/category/category_description" before="category.products"/>
        <move element="category.image" destination="content" before="category_desc_main_column"/>
        <referenceContainer name="sidebar.main" remove="true">
            <block class="Smartwave\Porto\Block\Template" name="category_view_custom_block" after="-" template="Magento_Catalog::category/custom_block.phtml"/>

For the mentioned page, I only want to remove the sub-categories that do not have further sub-categories.


Here is my category_filter.phtml

    $objectManager = \Magento\Framework\App\ObjectManager::getInstance();
    $category = $objectManager->get('Magento\Framework\Registry')->registry('current_category');
<?php if($category): ?>
    $categoryHelper = $this->helper('Magento\Catalog\Helper\Category');
<div class="block-category-list">
    <div class="block-title">
        <strong><?php echo $category->getName() ?></strong>
    <div class="block-content">
        <ol class="items">
        foreach($subcategories as $subcategory){
            if (!$subcategory->getIsActive()) {
            <li class="item">
                <a href="<?php echo $categoryHelper->getCategoryUrl($subcategory) ?>"><?php echo $subcategory->getName() ?></a>
    <script type="text/javascript">
    ], function ($) {
<?php endif; ?>

1 Answer 1


Remove Category option from Layered Navigation options list in magento2

This is what I did to remove the “Category” section from my layered navigation so I wouldnt have any repeat information with the attributes I wanted in the layered navigation. go to app/design/frontend/default/default/template/catalog/layer and open up view.phtml for edit.

<?php  if($filter->getName() != __('Category')) {?>
                <?php if ($filter->getItemsCount()): ?>
                    <dt role="heading" aria-level="3" class="filter-options-title"><?= $block->escapeHtml(__($filter->getName())) ?></dt>
                    <dd class="filter-options-content"><?= /* @escapeNotVerified */ $block->getChildBlock('renderer')->render($filter) ?></dd>
                <?php endif; ?>
            <?php }?>
  • hi @Saniya, Could you please be more specific, as the specified path do not exist for me. I am going to app/design/frontend/Smartwave/porto/.....Then I am not seeing any template folder in that. Please help in this
    – Umar M
    Commented Nov 21, 2018 at 6:38
  • Please go to this file path vendor\magento\module-layered-navigation\view\frontend\templates\layer\view.phtml please move this file in your theme folder and chec k it my above code
    – Rv Singh
    Commented Nov 21, 2018 at 6:48
  • I have one folder named "Magento_LayeredNavigation"
    – Umar M
    Commented Nov 21, 2018 at 6:49
  • Then I have layer folder-> templates->layer->view.phtml...is that correct?
    – Umar M
    Commented Nov 21, 2018 at 6:51
  • yes please check it in your side this file is call or not
    – Rv Singh
    Commented Nov 21, 2018 at 6:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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