How to take first post from the loop


Hi, I want to take the first post from the posts list to make it a different style. I used this code but it doesn’t work.
Can you take a look on it?

{{#foreach posts}}
    {{#has number="nth:1"}}
        <h4><a href="{{url}}" class="card-title">Long posts</a></h4>
    <h4><a href="{{url}}" class="card-title">Short post</a></h4>

Please let me know


@ENAMUL_HAQUE I think you want {{#has number="1"}} because you only want the single first post.

The nth:x syntax is saying “every x posts”, in your case because you’ve set it to "1" you’re effectively saying “every other post”.


Thank you for your reply.

I want my first post should come from different post card.
Like this:

{{#foreach posts}}
    {{#has number="nth:1"}}
        {{> "post-card-full"}}
    {{> "post-card"}}

But it is not working. All odd number posts are coming from this {{> "post-card-full"}} card.

How can I show only the first post?



I explained above :wink: You need number="1" not number="nth:1"


Thanks a lot. The problem is solved