If you catch your kitty urinating or defecating outside the box, say something to interrupt it, loud enough to hear for your kitten, but do not be scary. Then take your kitten to the litter box and set it on the floor. Call it litter training for kittens or whatever, but do it!
The principles of cat training might help to solve litter box problems if you have a new cat that has never used cat litter boxes before.
Mind that cats love routine. If you give food every day at the same time, their output will be just as scheduled. Lock the cat in the litter box room once time has come to crap. Make sure there is nothing else in the room that could keep your cat busy.
Odds are it will use the litter box. If the cat does, reward it with a treat. But please don’t torture the cat by keeping the door closed for a long time.
This trick will hardly work if your cat suddenly stops using its litter box. In that case something might be wrong.
Common reasons for litter box problems are:
The tray is dirty. Solution: clean it! You should clean a tray at least once a day, if possible after every time kitty used it. By the way, keep in mind that your cat has different ideas about hygiene than you. You may not see or smell anything dirty, but your cat might. An automatic litter box has a self cleaning system that works well.
Your cat doesn’t feel safe anymore in the litter box because of racket or noise. Solution: put the litter box in a quiet place.
Kitty has a medical problem. Urination or defecation may have become painful. Your cat might blame it to the box and urinate somewhere else. Advice: take your cat to the vet.
Your cat prefers a different type of litter. Solution: return to the previous brand or experiment till you have found something acceptable. Advice: always stick to the same brand.
If you have two cats or more, make sure every cat has its own litter box. No one likes the smell of cat urine. Not even cats like it.