Mughira bin Shuba reported,

The Prophet ﷺ 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 child is prayed over, and forgiveness and mercy are invoked for its parents."

Azami 3680

Sahih

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

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

الأعظمي 3680صحيح
Contents
Reference
Commentary
Ayat
Collection
Jami al-Kamil
Book
Funerals
Chapter
Deceased, carrying the funeral bier, and standing for it
Section
One walking going in front of the funeral, behind it, to its right, and to its left, and that the rider should be behind it
Numbering
Jami al-Kamil 3680 (2nd edition)
Azami 3680