If a man legally marries a woman after having illegal sexual relations with her, and she bears him a child six months after consummating the marriage legally, the child will be attributed to his father because he is believed to have come from a legal union.

If, however, (even after being legally married to him) she bears the child before six months, the child will not be attributed to the father, rather, he will be considered as an illegitimate child, then will only be attributed to his mother.

Similarly, if the woman confirms that she got impregnated by the man before he tied the knots with her, the child will still not be attributed to the father nor will he inherit him. Rather, he will inherit the mother and will be attributed to her only. 

However, by the virtue of legal kinship, the other children born to the man by the woman after legal marriage will be considered in Sharia as half-siblings from the mother’s side as he is not a recognized son of the man because he was birthed outside wedlock. It’s also established in Sharia that a child born out of wedlock inherits only the mother and not the father as he has no rights with the man.