Skip to content Skip to sidebar Skip to footer

How In Jekyll, For Categories.html Write A Logic For Posts In Specific Category Using Pagination?

I have posts with post.thumb and without post.thumb, and i want to show only posts with post.thumb in structure below without using limit and offset for posts. I have a categories.

Solution 1:

here is my solution that works, with help of JoostS

first of all I added to all my posts wich has post.thumb next tag (bg)

---layout:postthumb:"path/to/image/"bg:"yes"---

the next step is that I loop through all my posts with bg: "yes", by using filters.

so finaly here what i did:

<section class="type-one">
    <div class="row">

      {% assign posts = paginator.posts | where: "bg", "yes" %} // creating var//
      <div class="col-md-7"> 
      {% for post in posts limit: 1 %}
          {% include FirstPostInCategoryNews.html %}
      {% endfor %}
      </div>

      <div class="col-md-5 item-title-white">
          {% for post in posts limit: 2 offset: 1 %}
              {% include TwoPostsAfterFirstPostInCatNews.html %}
        {% endfor %}
      </div>

    </div>
</section>

2nd part:

<section class="others_posts_in_cat_news">              
            <div class="col-md-7">
                {% assign posts = paginator.posts | where: "bg", "yes" %}
                {% for post in posts limit: 4 offset: 3 %}
                {% include OtherPostsInCategoryNews.html %}
                {% endfor %}
            </div>                      
 </section>

if sombody didnt understand something, feel free to ask!

Post a Comment for "How In Jekyll, For Categories.html Write A Logic For Posts In Specific Category Using Pagination?"