The Prophet said: "The rider is to be behind the funeral (procession), and the walker where he wishes, and the child should be prayed over." (Using translation from Tirmidhī 1031)
عَنِ النَّبِيِّ ﷺ قَالَ «الرَّاكِبُ خَلْفَ الْجَنَازَةِ وَالْمَاشِي حَيْثُ شَاءَ وَالطِّفْلُ يُصَلَّى عَلَيْهِ»