Hey there.
I had this exact problem with my son. He actually had so much anxiety about pooping in the potty. With my son, he had tried to go in the potty early on in training and had 2 "bad" experiences. He is big for his age and when he sat on the training potty, the hole was too small and the poop got on him. He has always had a sensitive gag reflex, so it was almost traumatic.
So, I let him pick a toy at Target and put it up in the bathroom. Every day I encouraged, not demanded, that he try to go poop in the potty to get his toy. When he pooped in his diaper, I reminded him that "poop doesn't go in the diaper, it goes in the potty."
As time passed, I put him in underwear, but he still wouldn't go in the potty. He didn't go in his underwear either. He was holding it until I put him in a diaper! The poor kid almost made himself sick because he was afraid to poop in the potty, even though he peed there consistently!
Finally, one day I sat him down and I went through a step by step instruction on how to poop in the potty "When you feel like you have to go poo poo, I want you to come into the bathroom, pull down your pants and underwear, sit on the potty, and let the poo poo come out. When it is done coming out, you say, 'Mom, I'm done' and I will come clean you. Try it. It is important that you let it come out in the potty so you don't get a tummy ache. You will see that it is much better than going in your diaper, and then you will get your toy!"
We went over the steps several times until he was able to repeat it back to me. He went in the potty the very next time and ever since.
Every child is different. As mom's we have to play detective sometime and get to the bottom of what is going on in our kid's minds. Good luck!