<$mt:CategoryCount$>
The number of published entries for the category in context.
Attributes ¶
All <mt:CategoryCount> attributes are optional. The most common attributes are:
singular ¶
Allows special formatting for when the number of published entries in the category is equal to 1.
<$mt:CategoryCount singular="1 entry">
plural ¶
Allows special formatting for when the number of published entries in the category is greater than 1.
<$mt:CategoryCount plural="# entries">
none ¶
Allows special formatting for when the number of published entries in the category is 0 (zero).
<$mt:CategoryCount none="No entries">
or
<$mt:CategoryCount none="None">
Example ¶
List categories containing entries with a count:
<ul>
<mt:Categories>
<li>
<a href="<$mt:ArchiveLink type="Category"$>"><$mt:CategoryLabel$></a> (<$mt:CategoryCount$>)
</li>
</mt:Categories>
</ul>
List categories named “Bug Fixes” along with the number of published articles:
<mt:Categories>
<mt:If tag="CategoryLabel" eq="Bug Fixes">
<mt:SetVarBlock name="cat_news_count"><$mt:CategoryCount singular="1 article" plural="# articles" none="No articles"$></mt:SetVarBlock>
<$mt:CategoryLabel$> has <$mt:var name="cat_news_count"$>.
</mt:If>
</mt:Categories>
Gautam Patel
September 17, 2009 4:55 AM | Reply
All counts take the following additional (undocumented) attributes:
Where sometext is whatever you want.
Thus, this could be:
and it will say "1 entry", "2 entries" (or whatever number of entries it finds) or "No entries"
Dave Aiello
replied to comment from Gautam Patel
June 18, 2010 1:01 PM | Reply
The technique that Gautam suggested works. I added the attributes to the documentation and provided an additional example.