By default, article comments are sorted by date from the most recent to the least. You can add Date and Votes links that users can click to sort the comments by date or by the number of votes.
Note: The Date and Votes sorting links are available by default in standard themes and themes that were customized after the release of the new Community on November 30th, 2015.
Applicable template
- Article
Applicable HTML element
<section class="article-comments">...</section>
Recipe
- Insert the following div tag after the comment section's heading tag,
<h2>{{t 'comments'}}</h2>
, preferably after the{{#if comments}}
expression, if any, to ensure the sorters don't appear if nobody left comments yet:<div class="comment-sorter"> Sort by: {{#each comment_sorters}} <a aria-selected="{{selected}}" href="{{url}}">{{name}}</a> {{/each}} </div>
Example
<section class="article-comments">
<h2>{{t 'comments'}}</h2>
{{#if comments}}
<div class="comment-sorter">
Sort by:
{{#each comment_sorters}}
<a aria-selected="{{selected}}" href="{{url}}">{{name}}</a>
{{/each}}
</div>
<ul class="comment-list">
{{#each comments}}
...
Reference
Comments
0 comments
Please sign in to leave a comment.