Menu disappears when meta_key changed [closed]

if ( $query->is_main_query() && $query->is_singular ) {
            return;
}

This is the wrong way around – it’s actually ensuring that the query is being modified on everything except the main query, which is why it’s affecting the menus (which are also built using queries).

You need to change it to if ( !$query->is_main_query() && !$query->is_singular )

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