简体   繁体   English

Shopify Blog获得50篇以上的文章

[英]Shopify Blog get more than 50 articles

I have a shopify blog with over 150 articles in it 我有一个shopify博客,其中有150多个文章

{% assign countItem = 0 %}
{% for article in blogs.recipes.articles %}
    {% if countItem < 3 %}
        {% if article.tags contains product.title %}
        {% assign countItem = countItem | plus: 1 %}
        <li class="article">
            <a href="{{ article.url }}">
                <img src="{{ article | img_url: 'grande' }}" alt="{{ article.title }}" />
                <span class="title">{{ article.title }}</span>
            </a>
        </li>
        {% endif %}
    {% endif %}
{% endfor %}

However blogs.recipes.articles only returns 50. 但是blogs.recipes.articles仅返回50。

Any way to remove this limitation? 有什么办法可以消除这个限制?

Shopify limits the results to 50 so as to balance the server load. Shopify将结果限制为50,以平衡服务器负载。 As per shopify docs. 根据shopify文档。

Don't ever paginate a collection by more than 50, that's how many products maximum you should query per page. 分页集合不要超过50个,这就是每页最多应查询的产品数量。 Be respectful of Shopify's app servers. 尊重Shopify的应用服务器。 If you are not using any paginate tags, pagination does kick in behind the scene and you will only receive the first 50 products in said collection. 如果您没有使用任何分页标签,则分页确实会在幕后出现,并且您只会收到该系列中的前50种产品。

However I have tried to load more than 50 products by using paginate tag. 但是,我尝试使用分页标签加载超过50种产品。 But that slows the page load and also the page may become unresponsive if the number of records is large. 但是,这会减慢页面加载速度,并且如果记录数量很大,页面可能会变得无响应。 You can give it a try as following:- 您可以尝试以下操作:-

{% paginate blogs.recipes.articles by 500 %}
{% assign countItem = 0 %}
{% for article in blogs.recipes.articles %}
{% if countItem < 3 %}
    {% if article.tags contains product.title %}
    {% assign countItem = countItem | plus: 1 %}
    <li class="article">
        <a href="{{ article.url }}">
            <img src="{{ article | img_url: 'grande' }}" alt="{{ article.title }}" />
            <span class="title">{{ article.title }}</span>
        </a>
    </li>
    {% endif %}
{% endif %}
{% endfor %}
{% endpaginate %}

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

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