Comment count
Show "42 comments" next to your article links — one class, one script, no full widget.
Show the number of comments attached to a page — "12 comments" in an article list, on your homepage, in a related-posts block — without loading the full widget.
Step 1 — Mark the elements
Add a gc-counter element for each URL you want to count:
<!-- One element per URL to count -->
<div class="gc-counter" data-url="https://my.site/article-12345.html"></div>
<div class="gc-counter" data-url="https://my.site/article-67890.html"
data-uid="custom-uid-optional"></div>| Attribute | Required | Description |
|---|---|---|
data-url | ✅ | URL of the page |
data-uid | — | Custom UID, if the thread uses one different from the URL |
data-guid | — | Legacy GUID (WordPress compatibility) |
Usinguidon your threads?If your widget embeds set
behaviour.uid(recommended — see Getting Started), pass the same value indata-uidso the counter resolves the same thread.
Use the exact same URL as your embed
www.your-site.com/articleandyour-site.com/articleresolve to different threads. If thedata-urldoesn't match the URL (oruid) your widget embed uses, the counter shows 0 — or another thread's count. Use the same canonical URL everywhere.
Step 2 — Load the counter script
Add this once per page, replacing <shortname> with your site's shortname:
<script type="text/javascript">
function __semio__onload__counter() {
__semio__helpers_counter("<shortname>");
}
(function() {
var gc = document.createElement('script');
gc.type = 'text/javascript'; gc.async = true; gc.defer = true;
gc.onload = __semio__onload__counter;
gc.src = 'https://integration.graphcomment.com/helpers_counter.js?' + Date.now();
(document.head || document.body).appendChild(gc);
})();
</script>The script walks every .gc-counter element on the page and replaces its content with the corresponding comment count — plain text you can style freely with your own CSS (inline count, badge, etc.).
Need the count server-side?A public API endpoint returns the comment count as raw data — see
GET /api/pub/numberOfCommentsin the API Reference.
Next steps
- Getting Started — embed the full widget on your article pages.
- Widget configuration — thread identity (
uid) and every widget option.
Updated about 1 month ago
