How do I suppress a subcategory from appearing on the category list?

I can’t figure out how to get a subcategory (“Build your own teen innovation challenge” in this case) to stop showing up (the arrow) on the main category page. I’ve tried several things. Can you help?

2 Likes

I can’t find a site setting for this but you could hide it using CSS in a theme component.

Could use this CSS:

.category .subcategories {
      display: none;
    }

If you also don’t want them listed on the hamburger drop-down menu:

.category .subcategories, .category-links .category-link.subcategory {
  display: none;
}
3 Likes

So I’m familiar with CSS but not sure where to add it for Discourse to use it.

On the mobile so from memory but it’s something like this:

Admin
Customise
Themes
Components
Install (add name for new component)
Edit HTML/CSS
Apply theme component to themes

2 Likes

Another option… you could assign the sub-category to a group and restrict visibility to that group. Just fyi.

Would that have other consequences beyond the main categories page? I’ve not used groups yet.

You create a group called “Team Kids” then define who can join/view/participate in that group.

  • Add a description, allow certain people to be “owners” who can moderate the group vs regular members.

Create a Category as we did for “Classes & Events”

  • assign read/write/view access to the group under /Edit /Security for the category
  • Notice how you can also change settings for “Everyone”, which includes all anonymous guests on the web, etc.

OR

Simply stop the sub-category from showing up for @everyone. We restrict categories to only @trust_level_0 users, which means registered users who are logged in. Or, @trust_level_1 users who’ve been active on the platform a few weeks. These trust levels are actually all groups, too.

Hopefully this gives you some ideas on restricting your categories, rather than simply allowing them all to be crawled by google searches and viewed by random people online.

These are all very good suggestions; thank you. Ultimately, I was trying to create an Events group and then, in some cases, subgroups for the events underneath them. It’s an archive sub at this point, so I don’t need it front and center but don’t want to delete it.

Combined with @nolo’s CSS above, this worked perfectly. Thank you.

2 Likes

Category Group access is defined within each specific category, so you have total control over any access a group will (or will not) actually have to a category. “Trust Levels” of users in Discourse, Staff, Admins, Moderators… all of these are literally just groups.

This has been educational for me, so thank you, but I think you are solving a different problem to the one described in the original post. I get the impression he just wanted rid of the sub-category from the main categories page, but wanted it to behave normally otherwise.

1 Like

These are the only ways I know to suppress a category: by group. The trust levels are all groups. Use or ignore as you please.

Hi,

In my situation I invoked the hidden option to nest 2 sub categories under a parent and in that situation only the last nested sub category is hidden. Is there a way, via CSS to hide two layers deep.

e.g.
Parent Category
sub category 1 - hide
sub category 2 - hide

The CSS provided here in the above scenario only hides sub category 2.

.category .subcategories {
      display: none;
    }

Thank you.

You’d need to inspect the additional element with your browser dev tools and then add it’s class to the style declaration.

Thanks for the reply!

Note: I’ve invoke the hidden feature that allows for an extra nested category, 3 total vs 2.

Here is an example that might better illustrate the issue:
e.g., Main Page:
Test (Category)

  • Test - Sub 1 (nested Category of Parent Test Category)
    In this scenario,
.category .subcategories {
      display: none;
    }

works fine.
image
As you can see the nested test - sub 1 category isn’t displayed.

If I add another nested subcategory:
test - sub 2 category, with sub 1 category as it’s parent:
image
as you can see in the picture above, test - sub 2 is hidden
per the css code, but test - sub 1 is no longer hidden.

The problem is now two fold:
I can hide the test - sub 1 title, setting it’s class to display: none, but it also hides all of the parent categories on the main page.
The 2nd problem, is that even if I could isolate the and hide just the test - sub 1 nested category, the space it occupies is still there and will be problematic, I need to have about 20 more categories on the main page with two nest sub categories each.
Ideally I just want the end user to be able to click on the Test Category and have access to the other nested Categories, etc, which is easily accomplished, via
Show subcategory list above topics in this category.
and setting: sub category list styles to, e.g. boxes, etc.

If at some point I want to position another main page Cateogry after the Test Category, I don’t want 20 rows of blank linefeed, etc.

Thoughts?

Try this theme-component

Worked well - thank you!