Sunan an-Nasa'i
It was narrated that Al-Mughirah bin Shu,bah said: "The Messenger of Allah (ﷺ) said: The riders should move behind the Janazah and the pedestrian may walk wherever he wishes, and the (funeral) prayer should be offered for a child."'
أَخْبَرَنَا زِيَادُ بْنُ أَيُّوبَ، قَالَ حَدَّثَنَا عَبْدُ الْوَاحِدِ بْنُ وَاصِلٍ، قَالَ حَدَّثَنَا سَعِيدُ بْنُ عُبَيْدِ اللَّهِ، وَأَخُوهُ الْمُغِيرَةُ، جَمِيعًا عَنْ زِيَادِ بْنِ جُبَيْرٍ، عَنِ الْمُغِيرَةِ بْنِ شُعْبَةَ، قَالَ قَالَ رَسُولُ اللَّهِ صلى الله عليه وسلم " الرَّاكِبُ خَلْفَ الْجَنَازَةِ وَالْمَاشِي حَيْثُ شَاءَ مِنْهَا وَالطِّفْلُ يُصَلَّى عَلَيْهِ " .
Grade: Hasan (Darussalam)
Reference