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>
    {{/has}}
    <h4><a href="{{url}}" class="card-title">Short post</a></h4>
{{/foreach}}

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”.

1 Like

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"}}
    {{/has}}
    {{> "post-card"}}
{{/foreach}}

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?

Thanks

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

1 Like

Thanks a lot. The problem is solved