在Shopify中,如何设置最新评论的排序顺序?

在Shopify中,如何设置最新评论的排序顺序?,shopify,liquid,Shopify,Liquid,如何使最近的注释首先显示?我在文档中找不到这一点,目前我的评论已经过时了 这在我的文章模板中: {% for comment in article.comments %} <li id="{{ comment.id }}" class="comment{% unless number_of_comments > article.comments_count %}{% if forloop.first %} first{% endif %}{% endunless %}{% if fo

如何使最近的注释首先显示?我在文档中找不到这一点,目前我的评论已经过时了

这在我的文章模板中:

{% for comment in article.comments %}
<li id="{{ comment.id }}" class="comment{% unless number_of_comments > article.comments_count %}{% if forloop.first %} first{% endif %}{% endunless %}{% if forloop.last %} last {% endif %}">
{% include 'comment' %}
</li>
{% unless forloop.last %}
您可以使用for循环中的标记:

{% for comment in article.comments reversed %}
  ... do your thing
{% endfor %}

我不一定需要它们的反面,我需要它们按日期排序。现在它们完全是随机加载的,我很怀疑它们是随机加载的。根据Shopify的API文档;“评论是读者对博客中某篇文章的回应。评论按时间倒序出现在文章页面上”-这是真的,但如果您使用批量上传器导入它们,则不是。批量上传应用程序?听起来这就是问题所在
{% assign artComments = article.comments | sort: "created_at" | reverse %}
{% for comment in article.comments reversed %}
  ... do your thing
{% endfor %}