Display Comment Counts

Front End
Version 2.0.0-beta1+
2 min read

The {{ meerkat:count }} Antlers tag can be used to display the total number of comments for the current page. By default, the count tag will not consider comments that have not been approved, are marked as spam, or have been soft-deleted.

The following would display the total number of comments on the page:

<p>There are {{ meerkat:count }} comments!</p>

Customizing Filters

The comments that are counted by the count tag can be customized by supplying a value to the filter parameter:

<p>There are {{ meerkat:count filter="is:spam(true)" }} spam comments.</p>

Alternatively, we could limit the displayed count to only those comments left by the currently authenticated Statamic user:

<p>You have left {{ meerkat:count filter="user:in(*current*)" }} comments on this post.</p>

You may apply any filter from the Basic Filtering guide, or craft more advanced counts by utilizing the techniques from the Advanced Filtering guide.

Formatting Results

You may specify a custom number format by supplying the number_format parameter. This parameter works in exactly the same way as Statamic's format number modifier:

<p>You have {{ meerkat:count format_number="1|,|," }} comment(s).</p>

The format_number parameter was added in Meerkat 2.1.13-beta2.