- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
How to get count of comments for a specific post?
SOLVEJun 28, 2019 8:27 AM
I need to get the count of comments for specific post. I tried to use these functions:
blog_post_by_id(id)
content_by_id(id)
But both functions return empty list of comments and zero comments count. Is there exist any possibility to get count of the comments?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Accepted Solutions
Jul 17, 2019 9:48 AM
Just as an update here @roman-nich's code was perfectly valid but there was an issue on our end that was returning comment_count as 0 even if a post had comments.
{% set post = content_by_id(YOUR BLOG POST ID) %} {{ post.comment_count }} {{ post.comment_list }}
For example in the code above, if there was a comment on a post, the comment_count would return 0 and the comment_list would be an empty array. This has now been fixed up so that comment_count should return your comment number and your comment_list should return an array of the comments on the post.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content