【问题标题】:Shopify / Liquid - Count articles in blog without paginationShopify / Liquid - 在没有分页的情况下计算博客中的文章
【发布时间】:2021-02-02 17:05:30
【问题描述】:

我在 Shopify 上有一个包含 28 篇文章的博客。我为博客分页了 5 篇文章,即{% paginate blog.articles by 5 %}

我正在尝试统计博客中的文章数量,并尝试了以下两种方法:

方法一:


{% for article in blog.articles %}
  {% assign count = count | plus: 1 %}
{% endfor %}

{{ count }}

方法二:

{{ blog.articles.size }}

我面临的问题是,在这两种情况下,输出都是 5。我期望的答案是 28 - 显然它只是计算页面中的文章数量。我也在尝试按标签过滤,我想在其中查看标签搜索的结果数量。任何解决方案都将受到高度赞赏。

【问题讨论】:

  • 使用blog.articles_count 获取总数
  • @Onkar - 最好作为答案发布,可能带有指向 Shopify 液体参考中相关页面的支持链接:)

标签: shopify liquid


【解决方案1】:

当然,您需要检查默认的 Shopify 液体对象 blog 及其名为 articles_count 的属性,要查看 blog.articles_count 的相关信息,请使用此 documentation 链接。

【讨论】:

    猜你喜欢
    • 2021-08-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-04-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多