Like nerdatheart9490 said, the best way is to COMPLETELY fill your inventory with items villagers can't ask for or comment on. This means bells, flowers, or unidentified fossils. Personally, I use bells, because in addition to having full pockets, you want to have an empty wallet.
A full inventory and an empty pocket means villagers won't ask you to buy from them or sell to them. Also, don't have any tools equipped or in your inventory. Certain villagers might comment on them, like Peppy ones asking if you'd want a skull-shaped watering can or something.
What I personally do is, I dig holes around all my wandering villagers with the shovel. That way I know where they are when I get out of the water, and if you do it in a diamond shape, you can still talk to them through the gap when they ping you. Just make sure you don't lock villagers in the same box together. Then they'll talk and might get angry or sad and then they won't ping you. And make sure that after you lock everyone up, your shovel is put away, your wetsuit is on, and, again, your bells are crowding your inventory and not your wallet.
Lastly, make sure you dig holes to trap villager away from stumps, benches, or rocks, because I HAVE seen a certain villager of mine teleport out of his trap to sit on the bench instead, and it sucks, because there's no telling when he'll get down, and he won't ping while he's up there.
If you're looking for certain PWPs, by the way, make sure you have the villager type in question out wandering while you do this. Obviously you won't get a ping for, say, a zen bench if all your cranky villagers are in their houses.