You’ll often have post categories for things like “Events” that you don’t want showing up on your homepage with all your other posts. This is the easy way to filter them out.
We’ll use the
pre_get_posts hook to hop in right before the posts are pulled from the database and modify the query. For more information, see my post on customizing WordPress queries.