Skip to content

Instantly share code, notes, and snippets.

@mistermarco
Created October 11, 2013 17:52
Show Gist options
  • Save mistermarco/6939132 to your computer and use it in GitHub Desktop.
Save mistermarco/6939132 to your computer and use it in GitHub Desktop.
This block lists all the rest of the posts in a page's first category.
{% comment %}
This block lists all the rest of the posts in a page's first category.
{% endcomment %}
{% assign first_category_name = page.categories.first %}
{% for category in site.categories %}
{% if category.first == first_category_name %}
{% assign first_category_posts = category[1] %}
{% endif %}
{% endfor %}
{% if first_category_posts.size > 1 %}
<h3>Other posts about {{ first_category_name }}</h3>
<ul>
{% for post in first_category_posts %}
{% if post.url != page.url %}
<li><a href="{{ post.url }}">{{ post.title }}</a></li>
{% endif %}
{% endfor %}
</ul>
{% endif %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment