How to delete only the "box" category from the menu view?

Asked

Viewed 33 times

-2

I have searched but without success, I want the box category not to be displayed in a menu but not deleted, I just want it not to be displayed and continue to exist, this menu is all categories registered.

<ul class="list-menu-sidebar">
        <?php
            $categories = get_terms(array(
                'hide_empty' => false,
                'exclude' => 1,
                'taxonomy' => 'category'
            ));
            if($categories):
                foreach($categories as $category):
        ?>
        <li>
            <a <?php echo strstr($_SERVER['REQUEST_URI'],$category->slug) ? 'class="selected" ' : null;echo "id='$category->slug'" ?>href="<?php echo get_category_link($category); ?>">
                <em class="sas-icon icon-rss-squared"></em> <?php echo $category->name; ?>
            </a>
        </li>
        <?php endforeach;
        endif; 
        ?>
        <li><a <?php echo (strstr($_SERVER['PHP_SELF'], site_url('')))?"class='selected'":'';?> href="<?php echo site_url(); ?>/teste"><em class="sas-icon icon-export-1"></em> TESTE</a></li>
    </ul>

1 answer

0


Good morning, You could add an if inside the foreach by checking if the value treated in the loop execution is equal to 'Box'

if($categories):
   foreach($categories as $category):
      if($category->slug != 'Box'):
<?php 
   endif;
   endforeach;
   endif;
?>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.