How to sort the comments on Confluence page in reverse order
Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.
Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Except Fisheye and Crucible
Summary
How to reverse the order of comments on a Confluence page
Solution
As this is a Customisation, please test it in your stage environment before implementing it into Production.
- Go to Confluence Admin | Look & Feel | Custom HTML| Edit
- Add the below lines under "At the end of the head" section
<script>
function reverseCommentOrder() {
$comments = AJS.$('#page-comments');
$comments.children().each(function(i,li){$comments.prepend(li)});
}
AJS.toInit(function ($) {
// reverse the comment order
reverseCommentOrder();
// add a link to reverse the order
$('#comments-section-title').append('<a id="page-comments-reverse" href="#">(Reverse Order)</a>');
$('#page-comments-reverse')
.css({ 'color':'#999','font-size':'0.65em'})
.click(function (e) {
reverseCommentOrder();
e.preventDefault();
});
});
</script>
- Click on Save
Before Adding the customization
After Adding the Customization