It is narrated from Sayyiduna Ibn Amr (may Allah be pleased with him) that regarding a child who is attributed to his lineage after his father's death, and whose claim is made by the heirs of the deceased, the Prophet Muhammad (peace and blessings be upon him) gave this ruling: "If the child is from a free woman whom the deceased had married, or from his slave woman, then his lineage will be established from the deceased, but he will have no share in any inheritance divided before that, while he will receive his share of any inheritance not yet divided; and his lineage will not be established if his father had denied him. But if he is the result of sin with any free woman or slave woman, then his lineage will not be established from the deceased and he will not inherit, even if his own father claims him. He is the product of adultery and is the son of his mother, and he belongs to her family, whoever they may be, whether free or slave."
Hadith Referenceمسند احمد / مسند المكثرين من الصحابة / 7042