When are you hitting him before or after he pooped. The best thing to do would be to hit him after he has thrown away the food and begins crouching to poop, then hit him before he really starts pooping. This makes sure u punish the correct action. Make sure to stroke him when he poops on trees or rocks or wherever you do want him to poop or he might end up constipating. In the meanwhile feed him like Fenton Pat said, it has to work eventually Oh and while u do this dont give him the same sort of food all the time, give him diverse types of stuff you want him to eat, it might take a while, like a hour or longer depending on how old your creature is and how good the food pooping knowledge is.