Adding number of posts in each category

I am using Custom Header Links and wonder if it is possible to in it pass number of posts.

Does there exist a shorthand that grabs the current nr of posts for a specific category?

Like so:



Still looking to find out how to pass number of posts - by way of example we can see it being done in the docs view:

…it does not need to be in the custom header links. I also have a custom injected section on the start page that might be easier to pass it to.

Just wondering which code was used to catch them in the above screenshot or if there is (hope against hope) a shorthand?

To clarify: You want the number of posts per category, not the number of topics per category?

Either way I can say that it certainly is possible.

I am personally quite new to ember.js so I can only offer this in theory at the moment.

import Component from "@glimmer/component";
import Service, { inject as service } from "@ember/service";
import { action } from "@ember/object";

export default class CategoryStats extends Component {
  @service site
  categoryId = **input category id number**;
  postcount =[this.categoryId-1].post_count;


Because each category does keep track of the total number of posts, and the site keeps track of each category in a categories array, you could add an ember component like the one above and then output the {{postcount}} to the template from the Custom Header Links, or wherever else you’d like.

However, I am currently too dumb to know how pass in that categoryId value as an input, so I will have to punt this to someone smarter or more experienced.

After a night’s sleep, I realized that I could modify the original Custom Header Links theme component to let the categoryId be passed through the app settings.

I can’t promise this will work for you, but it functions on my test server. I do make the assumption that the category id’s match with their location in the site’s category id array. I’d recommend making your own copy of this and tweaking it to fit your needs.

1 Like

GLORIOUS BEING! Thank you. This solved everything. Looking good:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.