Join the Webstudio community

Updated 4 months ago

[Solved] Display limited number of posts (maximum 3) instead of all posts.

At a glance

The community member has a posts directory page that displays all posts from Hygraph, and they want to display a maximum of 3 posts on the homepage. They tried adding "[1]" after .data.data.posts but encountered an error. A community member suggested setting the limit in the GraphQL query, and another community member confirmed that adding first: 3 to the query solved the issue. The problem has been marked as [Solved].

I have rendered posts directory page that brings all posts from hygraph (from the tutorial)
I then created same 'Data variable' on homepage, and brought posts on homepage too

BUT on homepage i want to display maximum 3 posts (unlike on Directory i'll display all posts)
How can i limit it to maximum 3 posts

(P.S: I tried adding "[1]" after .data.data.posts but it shows error

Thankyou
Attachment
image.png
O
m
3 comments
set limit in your gql query
Great thank you Oleg for pointing me in the right direction

Posting for anyone else (like me who doesn't know GraphQL arguments and looking to do this)

added "first: 3" (Shown in screenshot)
Attachment
image.png
[Solved] Display limited number of posts (maximum 3) instead of all posts.
Add a reply
Sign up and join the conversation on Discord