I know that it can be really frustrating.. I don't think that Leo was completely potty trained until a bit over 1 years old... he was potty trained by 6 months but would have occasional accidents esp. when i left him at home (i think it was more spite)
anyways.. the way i did this was scold him when I caught him in the middle of peeing/pooing and picking him up and bringing him outside. Right when he started positioning himself to poo, I would pick him and RUN outside.. (sometimes poo would drop on the way) but he would get the idea that outside is the place to go. Because just yelling at the dogs after they go doesnt mean they know where they can go - they just think they cant go anywhere. Once he finished his business on the front steps, I would praise him and tell him hes a good boy (even though he initially tried to go inside and some turds or drips fell..haha)
When we went out for walks, everytime he did his business, I would give him a treat (milkbones or small piece of cheese)
eventually, everytime he lifted his leg or pooed, he would sit and wait for a treat because he knew he did a good job
Eventually, he realized that he should be going outside. I think its important to make sure your pup realizes that they need to go outside and not only think that they arent allowed to go.
Also, i never crated him.. he would whine too much. I would just watch him and the times he had accidents, i would clean up with a cleaner that you can buy at the pet store- it has a special ingredient so that the dog doesnt smell his urine and go on that spot again.
Anyways, i hope this helps and please try this before rehoming him
Edit to add: one more thing- dont scold him after he has done the act, only scold him if you catch him in the middle of peeing or pooing. He wont be able to associate why you are yelling at him and it wont be effective. But if you do catch him, make sure you say NO very firmly and move him outside and praise him.