0
votes

I have a blog with 28 articles in it on Shopify. I am paginating by 5 articles for the blog, i.e. {% 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. 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.

1
use blog.articles_count to get total countOnkar
@Onkar - That would be good to post as an answer, possibly with a supporting link to the relevant page in Shopify's Liquid Reference :)Dave B

1 Answers

1
votes

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.