Guinea pigs can be trained to go to the bathroom in a litter box. Some get the hang of it quickly, while some never learn. That's just how it is. Just remember that it’s not your guinea pig’s fault if they poop outside the litter box - sometimes they can have accidents or simply forget.
A Peruvian Guinea Pig all ready for training - maybe!
But some fresh bedding in the litter box and add some old bedding too, so that the smell is familiar to the GPs. Avoid cat litter, as it can be harmful to guinea pigs. If your guinea pig like to go to the bathroom in a particular place, that area is the ideal spot for the litter box.
Keep an eye on your pets - if they use the litter box, immediately offer a treat as a reward. The GP will come to associate using the litter box with being rewarded, increasing the likelihood that it will perform that action again. Remember, not all guinea pigs are able to learn this, so don’t be disappointed if you’re not successful.