Home Forums WoodMart support forum Hide specific categories from shop

Hide specific categories from shop

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #192423

    exe65
    Participant

    Hello,

    I want to hide specific categories from the shop – two at the moment. I have tried literally every code on the internet but nothing seems to be working. The only code that works is:

    Simple way to hide a category from everything except the admin backend:

    In functions.php:

    add_filter( 'get_terms', 'hide_category', 10, 1 );
    function hide_category( $terms ) {
      $new_terms = array();
      foreach ( $terms as $term ) {
        if ( $term->slug !== 'secret_category' ) {
          $new_terms[] = $term;
        } else if ( $term->taxonomy !== 'product_cat' || is_admin() ) {
          $new_terms[] = $term;
        }
      }
      return $new_terms;
    }

    If you want to only hide it from the shop, add || !is_shop() to the else if condition.

    But this just hides one categorie, it doesn’t allow me multiple choices. I’ve read somewhere on this forum that i should disable: Theme settings-Shop->sidebar&page title->categories in page title.

    Can you help?

    Thank you,

    #192527

    Artem Temos
    Keymaster

    Hello,

    Where exactly do you want to hide these categories? Please, send us a screenshot and link so we can check.

    Kind Regards

    #192530

    exe65
    Participant

    I want to hide them on shop/archive page – dropdown menu.

    #192640

    Artem Temos
    Keymaster

    It would be better to hide them with CSS code by their IDs

    .cat-item-335,
    .cat-item-329 {
    	display: none!important;
    }
    #192699

    exe65
    Participant

    That did the job! The amount of time i’ve spent solving this… thank you!

    #192702

    Artem Temos
    Keymaster

    You are welcome!

Viewing 6 posts - 1 through 6 (of 6 total)

The topic ‘Hide specific categories from shop’ is closed to new replies.