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.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)