If the gate was large enough for you to stand in and for him to pass through, get him gathered up on a short lead on the ground, 4 or 5 ft. Stand with your back against the post the gate is actually hung on. Make him pass through the gate in a half-circle back and forth in front of you, so that he is actually having to do lots of directional changes, and lots of moving his feet. At first, he will think that you are letting him get away with being where he wants, but later he will decide that this is a place of work! You will need to make him do half-circles through that gate until he is so bored he could fall over. It will be long after you're bored with it, but you cannot relax your shoulders, because he will see that you are bored too, and try to take advantage of you. So keep your shoulders back, and half-circle him for probably 10-15 minutes, or however long it takes him to lower his head and just do it.
When he does it, say, 10x consecutively, with no arguement, or 5x consecutively with no looks elsewhere, take him to a back part of the roundpen or arena, or wherever you were going to work, as far away from the gate as possible, and tie him facing away, and leave him (actually walk away) to think about what just happened for a good hour or two. My husband is at the barn daylight til dark, so I don't have a problem leaving my soured up horse tied all day, at all, because he is resting in a place I want him to choose to be.
When you are leaving to put him away for the day/night, make him make a few more passes at that gate, walk to the center of the arena, stop and pet him, then walk out.
He will pick up on the point pretty quick. Gate=work, arena/roundpen=rest. You'll probably have to work light in the arena/roundpen the next few times out, and may have to shoot him a quick reminder again a few times. But make the process part of your daily routine, since you have more than one gate, if possible, do a different gate every other time you go. Work the gate, work at the arena/roundpen, work the gate.
If he's doing it when you're on his back after all that, ride back and forth through the gate. But when you go to turn around, make him stop completely, sit on his hind end and spin around like a rollback. If you let him mosey around and turn, his circle can get bigger and bigger, and he could take advantage of you again. So to keep his mind on what he's doing, stop, rollback, walk. Stop, rollback, walk. Stop, rollback, walk. Until he gets it right.