The Prophet (ﷺ) used to go to the Quba' mosque, sometimes walking, sometimes riding.
Sahih al-Bukhari Book 96, Hadith 56