use*_*540 2 blogs loops shopify
我的 index.liquid 中有以下代码块
<div class="news-notable">
<h2>New & 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>
Run Code Online (Sandbox Code Playgroud)
在 h2 之后没有任何输出。我也试过只使用
{% for article in blogs.articles %}
Run Code Online (Sandbox Code Playgroud)
这也不起作用。在此先感谢您的帮助!
您需要在方括号内包含博客句柄。
例如,如果您的博客句柄是news
,那么您的 for 循环将是:
{% for article in blogs[news].articles limit: 4 %}
...
{% endfor %}
Run Code Online (Sandbox Code Playgroud)
或者:
{% for article in blogs.news.articles limit: 4 %}
...
{% endfor %}
Run Code Online (Sandbox Code Playgroud)