Mughira bin Shuba reported,

I believe Ziyad's family informed me that he traced this report back to the Prophet ﷺ, who said, "The rider travels behind the funeral procession, while the one on foot may walk behind it, in front of it, to its right, or to its left, staying close to it. The miscarried infant is prayed over, and forgiveness and mercy are invoked for its parents."

Abu Dawud 3180

Sahih

حدثنا وهب بن بقية عن خالد عن يونس عن زياد بن جبير عن أبيه

عن المغيرة بن شعبة

وأحسب أن أهل زياد أخبروني أنه رفعه إلى النبي ﷺ قال الراكب يسير خلف الجنازة والماشي يمشي خلفها وأمامها وعن يمينها وعن يسارها قريبا منها والسقط يصلى عليه ويدعى لوالديه بالمغفرة والرحمة

أبو داود 3180صحيح
Contents
Reference
Commentary
Ayat
Collection
Sunan Abu Dawud
Book
Funerals
Chapter
Walking in front of the funeral procession
Numbering
Darussalam 3180
Abu Dawud 3180