I have two girls who poop and pee absolutely everywhere, they are never ever clean!
I also have a mixed pair who live in my living room and have almost full access to it for most of the day while we are in. These two have never ever peed on the carpet, I get the occasional poop, but very rarely. They have a matt at the side of our sofa which they lay on throughout the day and go back to pee/poop inside the cage. I have never taught them, I think I’m very lucky. Their cage is exceptionally clean too, only one corner is poop corner
I really don’t know if you can train them? Rabbit yes but guinea pigs?