简体   繁体   English

Shopify中的博客循环无效

[英]Blog loop in Shopify not working

I have the following block of code in my index.liquid 我的index.liquid中有以下代码块

<div class="news-notable">
            <h2>New &amp; Notable</h2>
            <ul>
                {% for article in blogs[blog.news].articles limit: 4 %}
                <li><a href="{{ article.url }}">{{ article.title }}</a><br />
                <span class="date">{{ article.published_at | date: '%b %d, %Y' }}</span></li>
                {% endfor %}
             </ul>
        </div>

Nothing is being outputted after the h2. 在h2之后没有输出任何东西。 I've also tried just using 我也尝试过使用

{% for article in blogs.articles %}

And that didn't work either. 这也没有用。 Thanks in advance for the help! 先谢谢您的帮助!

You need to include the blog handle inside the square brackets. 您需要在方括号内包含博客句柄

For instance, if your blog handle is news , your for loop would be: 例如,如果您的博客句柄是news ,那么您的for循环将是:

{% for article in blogs[news].articles limit: 4 %}
...
{% endfor %}

or: 要么:

{% for article in blogs.news.articles limit: 4 %}
...
{% endfor %}

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

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