Potty training tips?

My child will only go to the potty if he is home. He will hold it in or go in his pants if we’re out on public. How can I have him tell me or have him go in public instead? We don’t go out for more than thirty minutes if possible and not to friends house because of this issue as well.