Using a litterbox in to which you start with some soiled bedding (so the scent attracts them, and tells them it's a good place to go/ make their mark) and then moving any wet bedding/ poops they subsequently do to there may help.
Mine are completely trained when they are out of the cage - they never go on the carpet/ floor. That was quite easy as they either go somewhere dark and covered (so I made little boxes with bedding in for them to visit at first), or they return to the cage (which is what they always do now). I used little veggie rewards whenever they went in the right place too.
But when I tried applying the technique to within the cage, they couldn't have been less receptive! They just go where they fancy - usually spreading it around as much as possible! Some pigs tend to favour one corner anyway though, and that makes it easier to convince them.
A lot of pigs seem to take to having a snooze in their litterbox, so if you have more than one pig, you may need to have one per pig as they're unlikely to turn another pig out so they can go to the loo in the right place!