[SOLVED]Searching for a post with a defined variable value


#1

Hi everyone,

  • I have a frontpage with a series of layout blocks. They can display 1, 2 or 3 articles (titles, tagline), like a tabloid newspaper.
  • I have a set of posts, each with a unique variable set in the front matter like postid: "4JNWEJPH"
  • My frontpage is including different layouts and assigning the content using these postid’s:

in the index.html

{% include layout1.html id1='4JNWEJPH' %}
{% include layout2.html id1='SDMZVLKN' id2='52G9A26T' %}

etc

in the layout1.html for example I’m trying to extract the content of the post with id1:

{% for post in page.posts %}
{% if post.postid == include.id1 %}
extracting headline, picture, etc
{% endif %}
{% endfor %}

PROBLEM: I’m missing something as this loop searching for the id1 doesn’t return anything…

  • I don’t have any error message
  • I tried removing quotes in the front matter variable declaration.No change.
  • Tried with {% if post.postid == include.id1 %} and {% if post.postid == id1 %}. No change.

-> I need a hint :slight_smile:
Thank you!


#2

Found the solution:
Of course it was:
{% for post in site.posts %} instead of {% for post in page.posts %}