get_query stops working after post filter

That’s because esf_admin_posts_filter() will apply itself to your query inside esf_get_teams() too!

Adding $query->is_main_query() to the if conditions inside your filter should prevent this.

tech