Mobs treat trap doors as solid blocks, even when opened, so they will never path to them. Simply surrounding them with trap doors, they are fearful of the walls basically. Having them in a pit can be optional, although it keeps them from walking on top. But for that case, make the walls the trap doors are attached to 2 high.