That was exactly the plan man. Just as Ramsey had scripted it. That's why he shot all his arrows into the battle to kill both Jon's and his own army; they made a point to emphasize this by having Davos stop his archers from shooting in fear of killing his own men -- a reasonable man would not shoot. But Ramsey, he had no problem sacrificing the lives of half his men to build a wall of bodies to trap John's army. He then brought in the shield wall to trap the Wildings; and specifically had the Karstarks go back up the other side of the wall to stop everyone else from climbing over. It was quite clever.