Is it true that you can get UTI from having sex?

Kind of. For women, sometimes having intercourse can bring certain pathogenic bacteria into closer proximitiy to the urethra, allowing the bacteria to ascend into the bladder and cause a uti. It's the reason why doctors recommend women go to the bathroom and void shortly after intercourse. For some women it is a definite problem (getting uti's after intercourse) but not everyone.