我的代码是:
<div class="recent-posts">
{% for post in site.posts | limit:3 %}
<div class="recent-posts-inline">
{% if post.featured-image %}{% include post-featured-image.html image=post.featured-image alt=page.featured-image-alt %}{% endif %}
<h4>
<a href="{{ post.url }}">{{ post.title }}</a>
</h4>
<p>{{ post.excerpt | strip_html | strip_newlines | truncate: 156 }}</p>
<p><a href="{{ post.url }}">Read More...</a></p>
</div>
{% endfor %}
</div>我试过使用where_exp过滤器,但没有用。这就是为什么我要再问这个问题的原因。
发布于 2019-11-17 03:30:38
在if-check中使用page variable。仅当帖子的标题与当前页面不同时才执行某些操作。如果要进行不同的比较,可以检查.url、.id或.name。
<div class="recent-posts">
{% for post in site.posts | limit:3 %}
{% if post.title != page.title %}
<div class="recent-posts-inline">
...
{% endif %}
{% endfor %}
</div>https://stackoverflow.com/questions/58892833
复制相似问题