Not a developer? Go to MovableType.com

Documentation

CategoryCount

The number of published entries for the category in context.

Attributes

Count Attributes

singular

Allows special formatting for when the number of published objects is equal to 1.

<mt:CategoryCount singular="1 category">

plural

Allows special formatting for when the number of published objects is greater than 1. # is automatically replaced with the number of objects.

<mt:CategoryCount plural="# categories">

none

Allows special formatting for when the number of published objects is 0 (zero).

<mt:CategoryCount none="No categories">

or

<mt:CategoryCount none="None">

Example

A simple example using the count attributes:

This returns

"1 category" or "9 categories" or "No category".

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:CategoryLabel> has
            <mt:CategoryCount singular="1 article"
                plural="# articles" none="No articles">.
    </mt:If>
</mt:Categories>
Back

1 Comment

Dave Aiello

Dave Aiello on June 18, 2010, 1:01 p.m. Reply

The technique that Gautam suggested works. I added the attributes to the documentation and provided an additional example.