Making a toilet for a rodent seems silly, but it's actually very easy to do and hamsters generally learn to use it pretty quickly if it'd done right. This method can also be used for rats and gerbils and another small animals.
The first step of making a hamster toilet is clean out the hamster's cage, but reserve a handful of bedding that has been used as a potty. The cage should be large enough for the hamster to be able to discern his or her potty area from the rest of the cage. In a tiny cage, the hamster will just go anywhere. Make sure to clean any urine from the sides and bottom of cage that the hamster might mistake for a toilet area.
The next step is to either purchase a hamster toilet from a pet store or use an empty glass jar that is large enough for the little guy or gal to enter and turn around comfortably. Set the hamster toilet or sideways glass jar in a corner of the cage that you'd like the hamster to use. If when you cleaned the cage, you noticed that the hamster went mostly in one corner, that's a good corner to use as a hamster toilet!
Then, you can either use torn up toilet paper or paper towels to make the litter. Make sure the paper is not bleached or otherwise chemically treated. You can also use litter sold at pet stores specifically for hamster toilet use. Place this litter in the toilet. This is where you grab a bit of the soiled bedding and place it in the hamster toilet to make it smell like a potty area.
Next, the last step to make a hamster toilet is to put your little hamster back in the cage! The hamster should smell the urine that you placed in the toilet and begin to use it. Hamsters do tend to go number two when they're walking around so they may not be as likely to use the hamster toilet for that, but it'll certainly keep the cage cleaner a bit longer. Remember to take the toilet out once a day and clean it out, but put a little bit of soiled litter back in to keep your hamster remembering that it is his potty!
Now, you've successfully made a hamster toilet and can depend on less litter changes as long as you keep the toilet relatively clean. If you let it get too gross, your hamster may not want to go in his potty and will just use the rest of his cage. It may also help to make him a separate little place for a pet so he isn't tempted to cuddle in the toilet!