In "Biblical Perspective" Gordon Snider writes concerning Psalm 24:7:
The background of this Psalm seems to have been a procession of worshipers, perhaps Levites, accompanying the ark of God as they approached Jerusalem. As they approached the city, a part of the group would sing, Lift up your heads, O ye gates. While the previous verses spoke of the need for people to prepare to ascend “the hill of the LORD,” the psalmist here figuratively called on the city gates themselves to prepare for His entrance. The meaning of the imagery of the gates is unclear — whether the gates of the Temple, of eternity, of the city of Jerusalem, or some other gates. But the focus is upon the King of glory.
Source: Studies in the Psalms: Adult Teacher's Insights, page 19.