liquid - Exclude current post from recent posts query in Jekyll? -
so heres recent posts query last 5 posts.
{% post in site.posts limit:5 %} <li> < href="{{ post.url }}">{{ post.title }}</a> </li> {% endfor %}
however, shows current 1 too, if 1 of 5 latest posts. tried include if statement check url, how can add +1 limit variable?
p.s.: included space in anchor tag readable code
checking url should work. loop on 6 items , hide last 1 when not find match.
{% post in site.posts limit:6 %} {% if post.url != page.url %} {% if forloop.index < 6 or found %} <li> <a href="{{ post.url }}">{{ post.title }}</a> </li> {% endif %} {% else %} {% assign found = true %} {% endif %} {% endfor %}
Comments
Post a Comment