I’m creating a website for community and I have a forum. I want to have a “hot posts” section in the main page, so I want to display only posts from the recent time (only couple hours) but still sort them by likes. I just want to have the most liked posts of the forum from the recent time. Is it possible? how?
(btw: sorry for my bad english…)
To access the post [database:](database:
Velo: Wix Forum "Posts" Collection Fields | Help Center | Wix.com)
[Velo: Wix Forum "Posts" Collection Fields | Help Center | Wix.com](database:
Velo: Wix Forum "Posts" Collection Fields | Help Center | Wix.com)
To sort the post by Like Count (likeCount): (The largest count will go to the top, least liked will sink to the bottom)
https://www.wix.com/velo/reference/wix-data/wixdataquery/descending
To limit the post query: (You may only show 3 hit post)
[https://www.wix.com/velo/reference/wix-data/wixdataquery/limit](query:
https://www.wix.com/velo/reference/wix-data/wixdataquery/limit)
Only get the post that is updated/released within 24 hours: Last Activity Date (lastActivityDate)
https://www.wix.com/velo/reference/wix-data/wixdataquery/ge
const today = new Date()
const yesterday = new Date(today)
yesterday.setDate(yesterday.getDate() - 1)
.ge("lastActivityDate", yesterday)
‘Send’ the data to repeater:
‘Show’ the data in repeater:
$w("#myRepeater").onItemReady( ($item, itemData, index) => {
$item("#title").text = itemData.title
});
Thank you so much! can I write you here If I’ll have questions? because I’m pretty new to this…
Is there an api to create a post programatically as well ?