get posts logic