Added check for is_main_query to stop weird things from possibly happening