gpt4 book ai didi

loops - Shopify 中的博客循环不起作用

转载 作者:行者123 更新时间:2023-12-02 04:57:52 25 4
gpt4 key购买 nike

我的 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>

h2 之后没有任何输出。我也试过只使用

{% for article in blogs.articles %}

那也没用。在此先感谢您的帮助!

最佳答案

您需要在方括号内包含博客句柄

例如,如果您的博客句柄是 news,您的 for 循环将是:

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

或:

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

关于loops - Shopify 中的博客循环不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17642344/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com