2

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

这也不起作用。在此先感谢您的帮助!

4

1 回答 1

5

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

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

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

或者:

{% for article in blogs.news.articles limit: 4 %}
...
{% endfor %}
于 2013-07-15T08:45:04.567 回答