The Messenger of Allah ﷺ used to visit Quba both riding and on foot.
أن رسول الله ﷺ كان يأتي قباء راكبا وماشيا.
Malik narrated it in the chapter on shortening the prayer (71), from Nafi, from Ibn Umar, and he mentioned it. In the version of Abu Musab, from Malik, from Abdullah bin Dinar, from Abdullah bin Umar, he mentioned the same. Sharh al-Sunnah (458).Muslim narrated it in the chapter on Hajj (518/1399), from Yahya bin Yahya, who said, "I read to Malik, from Abdullah bin Dinar," with the same wording through this chain. This is how Muslim narrated it from Yahya, but I did not find the route of Abdullah bin Dinar in Yahya's version, only the route of Nafi, as mentioned before.Bukhari narrated it in the book on the merit of prayer in the masjid of Makkah and Madinah (1194), from Musaddad, from Yahya (bin Saeed Qattan), from Ubaydullah, from Nafi, with the same wording.