Abu Jubair bin Hayyah narrated that he heard Mughirah bin Shu’bah say: “I heard the Messenger of Allah (ﷺ) say: ‘The (funeral) prayer should be offered for a child.’”
It was narrated from Jabir bin ‘Abdullah that the Messenger of Allah (ﷺ) said: “If a child utters a sound (after being born), the funeral prayer should be offered for him and (his relatives) may inherit from him.”
It was narrated that Abu Hurairah said: “The Prophet (ﷺ) said: ‘Offer the (funeral) prayer for your children, for they have gone ahead of you (i.e. to prepare your place in Paradise for you).”