We have a cat, adopted approximately one year ago from a shelter as a kitten. He was fostered in a family home - I don't believe he spent any time actually in the shelter. He is currently approximately 14 months old.
He has two litter boxes, one upstairs in the hall between the bedrooms, one tucked in a corner of the family room downstairs. We use pine litter, which he has used since before we adopted him and we change the litter at least once a week and wash the litter boxes approximately every 1-2 weeks. He knows where the litter boxes are and for the most part (maybe 80-90%?) he uses them for both wet & dry elimination.
But sometimes he goes other places. There does appear to be a pattern to where he goes: he mostly prefers baskets or other things with tall sides and fabric in them. For example, a hamper with dirty clothes in it or a basket containing blankets. Occasionally he will break this pattern: for example, this morning we had a load of towels for the laundry - the load was a little too large, so two towels were left behind on the floor in the closet and he peed on them. Interestingly, he had used one of his litter boxes 15 minutes earlier to defecate.
As for why he goes, this is a mystery. Sometimes it seems he may be doing it in response to an upset. This morning he was scolded (gently) and removed from the counters in the kitchen where he is not permitted to go. Other times he seemed like he might be upset with us for being out all day and leaving him alone at home (yesterday was one such day).
I have noticed two occasions in which he displayed certain behavior before an improper elimination: on these two mornings he was especially crazy - meowing loudly (he's normally quite quiet) and much more active than usual (zooming around the house, playing crazily). Normally evening is his play time, when we're all around to play with him. I have only noticed this twice, but it does seem to be predictive of an attempt at improper elimination (the first time ended with him defecating in a trash basket in the rest room). This morning, in fact, I did spend some time playing with him, hoping that I could satisfy whatever need he had - he seemed to enjoy it and did seem to play until he was done, but still peed on the towels in the closet.
Most of the discussion of cats & litter boxes that I've seen online seem to be centered around making the litter box more attractive or more to the cat's liking - for example this question seems to be about a change to elimination in response to stress or upset, but the accepted answer seems to be mainly about changing the litter. Our cat does not seem to have a problem with his litter boxes - he uses them just fine most of the time.
We have tried changing things up with the litter boxes - we got him larger litter boxes (his old ones were kitten sized) and we added a litter box attractant (this one) which he seems to like - he checked it out closely the first time we used it. We have also taken him to the veterinarian, with no issues found. We are considering moving ahead with some of the steps described in other answers (trying different litters, changing locations), but to be honest, that does not seem to be the problem here.
Does anyone have any suggestions?