All perfect praise be to Allah, The Lord of the worlds. I testify that there is none worthy of worship except Allah and that Muhammad is His slave and Messenger.
If the dead is a female and the person who is praying the funeral prayer does not know that the deceased is a female, or if he is unable to supplicate for her using the feminine gender, then he may supplicate with the masculine gender, as if he is referring to the deceased as "this person".
Ibn ‘Uthaymeen was asked, “If the praying person does not know whether the dead person who is presented for the funeral prayer is a male or female, does he use the feminine or the masculine gender?”
He replied, “It is permissible for him to use either the masculine gender or the feminine gender depending on the intention; so if you say, ‘Allahumma ighfir lahu’, intending to say 'for this person' or 'for the dead' (both are masculine in Arabic); and if you say ' Allahumma ighfir laha’, intending to say 'for this funeral' [i.e. for the Janaazah (funeral), which is feminine in Arabic and may be used whether the dead is a male or a female].”
As regards a child, then we do not supplicate for him with this supplication, but we supplicate that Allah makes him a preceding reward and a stored treasure for his parents and an intercessor for them, and the like, and one supplicates for his parents to be patient and that their scale of good deeds be heavy due to the child’s death, and so forth.
In case there is a funeral prayer of an adult and a child together, then one supplicates for the adult with appropriate supplication and for the child with appropriate supplication. For more benefit, please refer to fatwa 339799.
In case one does not know the authentic supplication according to the Sunnah, then he may supplicate with any supplication for the dead, and by doing so, he would fulfill the obligation; such as by saying, ‘O Allah forgive him’, ‘O Allah have mercy upon him’, and the like.
If a person does not supplicate for the dead in the funeral prayer, then his prayer is not valid as he has left out one of its pillars.
Allah knows best.