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 3766

Sahih

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

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

الأعظمي 3766صحيح
Contents
Reference
Commentary
Ayat
Collection
Jami al-Kamil
Book
Funerals
Chapter
Children of Muslims and polytheists
Section
Prayer over the children of Muslims and their miscarried fetuses
Numbering
Jami al-Kamil 3766 (2nd edition)
Azami 3766