Showing number of comments on blog index page (or elsewhere)

If you want to show the number of comments for your blog posts somewhere else on the article page, or on the blog index page, you can add this code to your theme to display this information.


{% comment %} Ensure you add this in a file that has access to the {{ article }} object {% endcomment %}
{% assign replyComments = article.metafields.bb_comments.comment_list | map: 'replies' %}
{% assign parentComments = article.metafields.bb_comments.comment_list %}
{% assign totalComments = parentComments.size | plus: replyComments.size %}
{% if totalComments > 0 %}
<span>{{ totalComments }} comments on this article</span>
{% endif %}

This is how it looks on my development theme:


Give it a try and let us know if you have any issues!

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us