Hi! You can get the total amount of comments by calling the count
field on the comments relation.
Sorry But I don't understand and I can't get the specific post total comments so please help me.
Our sincere apologies for the delay in response.
Let assume you have attached the comments to the Post
model and your model variable is called post
. In order to get the comment count on that particular model, you can call the count()
method on on the comments relation of the model. Like so:
{{ post.comments.count() }}
When I use {{ post.comments.count() }}
it's not count all comments on a post.
For example on this page: https://www.kvntravel.nl/blog/europa/nederland/evenement-deventer-op-stelten-2019
I'm using this code to show in the top an icon including the number of comments. When you click on it (or scroll down), you see more comments visible. Because one of the comment is a reply on a comment.
How can I count all comments together?
1-5 of 5