Use in_the_loop() to ensure that only the single post in the main query is filtered.