2
我想循環瀏覽網站上除帖子unlisted
以外的帖子。我可以通過在for循環中嵌套if語句來完成此操作,但是當我還想指定limit
時,這種情況就會崩潰 - 循環將僅運行5次,而不管帖子是否通過檢查。循環遍歷液體中某些類別的帖子的所有列表
{% for post in site.posts limit: 5 %}
{% unless post.categories contains 'unlisted' %}
<!-- display post -->
{% endunless %}
{% endfor %}
我需要傳遞一個已經過濾的列表for循環,但我不能這樣做,主要是因爲我無法找到一種方法來where
濾波器contains
和否定結合:
{% for post in site.posts | WHERE CATEGORIES NOT CONTAINS 'UNLISTED' | limit: 5 %}
<!-- display post -->
{% endfor %}