The following refers to the Desert Temple from Spirit Tracks, the name given to the Sand Temple in the European version of the game.
To enter the temple, three challenges must be accomplished.
1.Navigate through tracks similar to the Lost Woods. You will end up at the beginning if you go the wrong way.
2.Defeat a Rocktite
3.Destroy all of the turrets around the Temple entrance. After all have been defeated, the entrance is opened.
Just a little note: the Rocktite comes first, then the twisted tunnels.