Created
October 11, 2013 17:52
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% 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