All perfect praise be to Allaah, The Lord of the Worlds. I testify that there is none worthy of worship except Allaah and that Muhammad is His slave and Messenger.
The illegitimate child born out of wedlock is entitled to inherit from his mother only, and she inherits from him as well; he is not entitled to inherit from the biological father, even if he married the mother with whom he had fornicated later on because this child is not his legitimate child, as highlighted in fatwa 84788.
The right to inheritance is based on the affirmation of lineage; the illegitimate child is not attributed to the biological father according to the majority of Muslim scholars. Therefore, an illegitimate child is not entitled to inherit from his biological father. However, some scholars held that if the biological father received the due hadd (corporal punishment prescribed by the sharee'ah) for adultery, then the inheritance rights are established (i.e. the illegitimate child would then be entitled to inherit from his biological father). The opinion of the majority of Muslim scholars is the one adopted in Islamweb.
The Kuwaiti Encyclopedia of Islamic Jurisprudence reads:
"Inheritance of the illegitimate child: Muslim jurists maintained that the child born out of wedlock is entitled to inherit from his mother and her relatives and that they also inherit from him according to the share specified to them in the Islamic law or by taʻseeb (i.e. by virtue of having a paternal relation with the deceased and not having an allotted share, so one gets what is left after the allotted shares have been distributed); and his paternal relatives are the paternal relatives of his mother. As regards him inheriting from the fornicator and his relatives, the majority of the scholars are of the view that it is prohibited because he has no relationship of lineage with them, and that relationship is the legal cause for inheriting from each other. Therefore, if a man commits fornication with a woman and she gives birth to a child and he then he marries that same woman afterwards and she gives birth to a second child, then the two children would be half-brothers from the mother's side, and they inherit from each other only according to this basis. However, Al-Hasan and Ibn Seereen held that the child born out of wedlock is to be attributed to the fornicator if the hadd is implemented on the fornicator, and he (the child) inherits from him in this case."
It also reads:
"Is-haaq ibn Raahawayh, Ibn Taymiyyah, and others are of the view that the relation of the child born out of wedlock to the one who fornicated with the mother is affirmed because his fornicating is a confirmed reality; so in the same manner that the child's relation to the mother is affirmed, the relation to the fornicator is also affirmed so that the lineage of the child is not lost and he is not harmed and shamed for a crime that he did not commit, as Allaah, The Exalted, says (what means): {…and no bearer of burdens will bear the burden of another.} [Quran 6:164] This scholarly view necessitates that inheritance between the child and the fornicator is affirmed because inheritance is based on the affirmation of lineage, and they (these scholars) affirm it in the situation mentioned."
Based on that, if the fornicator wishes to attribute the child to himself and the child's mother was unmarried, then the majority of scholars maintained that the child is not to be attributed to him. This is the scholarly view adopted in Islamweb. Some scholars held that if the father wishes to attribute the child to himself, then the child should be attributed to him (since he acknowledges paternity). Each scholarly view is supported with evidence and you are free to follow either of them. Following the scholarly view suggesting that the illegitimate child may be attributed to the father if he acknowledges paternity should not be criticized (neither of the two scholarly views should be imposed on anyone).
Allaah Knows best.