Comment Count
The {{ meerkat:comment_count }} tag returns the number of comments on the current thread. It is a self-closing tag.
#Examples
1<p>{{ meerkat:comment_count }} comments</p>
1<p><s-meerkat:comment_count /> comments</p>
1{{ if {meerkat:comment_count} > 0 }}
2 <a href="#comments">Jump to {{ meerkat:comment_count }} comments</a>
3{{ else }}
4 <a href="#comment-form">Be the first to comment</a>
5{{ /if }}
1@php($count = Statamic::tag('meerkat:comment_count')->params(['thread' => $id])->fetch())
2@if ($count > 0)
3 <a href="#comments">Jump to {{ $count }} comments</a>
4@else
5 <a href="#comment-form">Be the first to comment</a>
6@endif
#Parameters
| Parameter | Default | Notes |
|---|---|---|
thread / from_thread |
current context | Choose a specific thread, or "*" for a public count across every thread. |
include_unpublished |
false |
When true, include pending, rejected, and spam comments. Requires view comments. Meerkat ignores it for public callers. |
include_tombstones |
false |
Include removed comments when the viewer has view comments. |
include_tombstone_replies |
false |
Include replies beneath removed comments when the viewer has view comments. |
site / locale |
current site | Restrict to one site. Pass * for an all-site count, including authorized include_unpublished counts. |
Separate thread IDs with a pipe (thread="a\|b") to add their counts together. Use thread="*" to count across all threads.
#Performance
Each call runs a count query. When listing many entries, cache the template fragment or load the counts in application code.