DS will be 5 next week. he was potty trained after just after he turned 3yo. Birthday, christmas out of the way and then went for it.
Wees were great,easy, done in a few days or so.
Poos.. well... we are pretty much there... almost.
My DS behaved exactly like yours, the hiding, the not liking the loo, waiting till you are busy, holding it, over flow..
Not long after we started potty training, He had a bad tummy, and messed himself in public, and this set us back over 1 year. I'm told this is very common when this happens, and I have to say it's been really tough at times.
In the end I asked the HV about a year ago and she told me to do a star chart, reward with stickers and praise every poo, even those in his pants to begin with!
praise every trip to the toilet. Draw a star chart, get stickers for when he sits on the toilet, then more stickers when he does a poo and a small treat.
We said he will get a 'try' sticker, and if he manages to do a poo in the loo, a rewad every time.
Then
If he gets 3 try stickers he gets a reward, then you can extend this to 5, but he'll generally do a poo by 5th.. as long as you know the signs to watch for, so will get a reward anyway!
After meals, after bath, when he goes quiet.
Main thing (and this is so bloody hard) is not to get cross when he does a poo in his pants, praise him.
If he is like my DS it's his control mechanism. if he is worried about things he may do it in his pants.
He was nearly getting the hang of it and then DH trip home was postponed.
nearly there again and we had a land lady from hell situation where I had to call police and we had to find another house to move to.
When we moved to this house he just clicked, he was happy and safe and it was no issues at all.
Then came the run up to Reception. He started again. 
We are pretty much getting there again. he is settled in school, we are 8/10 at the moment.
we never took anything medicine wise, lots to drink, fruit and veg and lots of happy praise, even while you are scrubbing pooey pants....
FWIW, if he is OK on wees, then persevere but do the chart thing and the praise.
I'm betting the unsatisfactory nursery could be a factor.
the above encourages him to get into the habit of poos, to not fear them, and to let them out. You can do it.