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.
This child is not considered as the child of that man Islamically; rather, he is born out of Zina (fornication or adultery), and so, he is traced back to his mother. For more benefit, please refer to Fatwa 89082.
However, some scholars are of the view that if the fornicator asks that the child be traced back to him, then he is traced back to him, but the first opinion is the view of the majority of the scholars and it is the view that we consider to be the most preponderant one.
Besides, the marriage of the fornicator with the woman with whom he fornicated before making sure that she is not pregnant is a controversial matter among the jurists as well. Some of them consider it to be valid and some of them consider it to be invalid. Therefore, according to the first opinion, this marriage is valid. For more benefit, please refer to Fatwa 84788.
Nonetheless, whoever has committed Zina, must take the initiative to repent and avoid any means that could lead to Zina again, like such sinful relationships. For more benefit, please refer to Fataawa 81786, 81356 and 87903.
Allaah Knows best.