The main reason that I would get all the posts and loop through them multiple times is only because that way I’d only be doing one query, and additional queries will slow down the page. In the end the amount of code the way you do it may be slightly more.