Show all categories in the home page (including muted ones), but don't show its topics in the latest posts

So, our home page displays two columns: categories on the left and the latest topics on the right.

Topics in one category gets updated automatically, so I’d like to hide it from the right column (latest).

However, I don’t want to mute that category for all users - it looks really bad that it’s hidden in the “Muted” aka-spoiler in the home page.

Any ways to work around this issue?

1 Like

Last updated ~2 years ago. I’m worried about potential compatibility issues.

The ideal case would be to solve my goal with using standard means.

How about creating a subcategory, and setting the parent category to not include topics from the subcategory in the default list filter?

Will that affect the “Latest” list shown in the Category+Latest home page?

Another issue is, if someone mutes the category, it won’t affect what is shown to anonymous users, right?

In my case, I’d like to achieve consistency. I need a fully fledged category that behaves like a normal one, except that its new topics and updates are not shown in the Latest at home page.

To be honest, I’m not sure without mirroring your set-up. :slightly_smiling_face: Though you can also default mute the subcategory as an option too (or change the visibility in the security settings). You may need to try a few combinations and see if any get you close to what you want.

If a user Mutes something (a topic, category, tag, or another user) it only counts for them, and has no effect on anyone else.

You’d have to use the default mute options in the Admin setting to make it global, and even then a user could override them.

Yup. So that’s why I’m here - because I could not solve the problem after trying quite a few variations I could think of.

Having a parent category that’s regular, and a subcategory that’s default muted seems like it would get you close?

Or perhaps a muted tag instead?

That view shows 20 topics by default. So, unless that specific category gets a lot of topics bumped - whether it be new topics or replies - I think it’s fine just to hide those topics.

You have two options.

  1. With JavaScript in your theme’s header tab
<script type="text/discourse-plugin" version="0.8">
  const { on } = require("discourse-common/utils/decorators");
  const ignoreCategoryId = 6;

  api.modifyClass("component:categories-topic-list", {
    @on("didReceiveAttrs")
    removeCategoryTopics() {
      const filtered = this.topics.filter(
        ({ category_id }) => category_id !== ignoreCategoryId
      );

      this.topics = filtered;
    },
  });
</script>

This prevents the markup for the topics from being rendered altogether. Change ignoreCategoryId to the id for the category you want to target. You can find that by visiting that category and checking the URL in your browser.

https://meta.discourse.org/c/support/6 <---- last digit is the category id
  1. With CSS… if it’s a top-level category
.latest-topic-list-item.category-SLUG {
  display: none;
}

if it’s a child category

.latest-topic-list-item.category-PARENT_SLUG-CATEGORY_SLUG {
  display: none;
}

Anything beyond that will require a plugin or a change in core as far as I know.

1 Like