How to structure database in order to lookup and store post ID's in one PostgreSQL command?
you can use join table for example

select p.id, p.userid, p.content
from post p
join userinfo ui on p.userid=ui.id
order by created_date desc
limit 5


or you can use CTE feature (imagine two table as one table)

Reference
https://www.postgresql.org/docs/11/tutorial-join.html
https://www.postgresql.org/docs/11/queries-with.html