简体   繁体   English

Shopify / Liquid - 计算博客中的文章而无需分页

[英]Shopify / Liquid - Count articles in blog without pagination

I have a blog with 28 articles in it on Shopify.我有一个博客,里面有 28 篇关于 Shopify 的文章。 I am paginating by 5 articles for the blog, ie {% paginate blog.articles by 5 %}我为博客分页了 5 篇文章,即{% paginate blog.articles by 5 %}

I am trying to count the number of articles in the blog and have tried both the following methods:我正在尝试统计博客中的文章数量,并尝试了以下两种方法:

Method 1:方法一:


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

{{ count }}

Method 2:方法二:

{{ blog.articles.size }}

The issue I am facing is that in both cases, the output is 5. The answer I am expecting is 28 - clearly it is only counting the number of article within the page.我面临的问题是,在这两种情况下,output 都是 5。我期望的答案是 28 - 显然它只是计算页面中的文章数量。 I also am trying to filter by tags, where I want to see the amount of results from the tag search.我也在尝试按标签过滤,我想在其中查看标签搜索的结果数量。 Any solutions would be highly appreciated.任何解决方案将不胜感激。

Sure, You need to check the default Shopify liquid object blog and its property named articles_count , to check about blog.articles_count use this documentation link.当然,您需要检查默认的 Shopify 液体 object blog及其名为blog.articles_count articles_count文档链接。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM