Limited the query for display posts and moved the queries to functions for readability.