the Messenger of Allah said: "The rider should move behind the Janazah and the pedestrian may walk wherever he wishes, and the (funeral) prayer should be offered for a child."
أَنَّ رَسُولَ اللَّهِ ﷺ قَالَ الرَّاكِبُ خَلْفَ الْجَنَازَةِ وَالْمَاشِي حَيْثُ شَاءَ مِنْهَا وَالطِّفْلُ يُصَلَّى عَلَيْهِ