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.
Trying to get and wishing for a child are among the practices of Prophets and the righteous. Allah Says (what means): {And We have already sent messengers before you and assigned to them wives and descendants.} [Quran 13: 38]
Allah informed us about His Prophet Zakariyyah in the Quran that he asked Allah saying (what means): {So give me from Yourself an heir.} [Quran 19: 5]
Allah also said describing the distinguishing qualities of His Slaves (what means): {And those who say, "Our Lord, grant us from among our wives and offspring comfort to our eyes and make us an example for the righteous."} [Quran 25: 74]
Imam Al-Bukhari entitled in his Saheeh many chapters that prove the permissibility of asking for children. He entitled a chapter with this title: “Seeking to Beget Children" and another chapter with the title "Invocation for Increase of Offspring.”
The Prophet used to supplicate Allah for his companions to increase their offspring. Anas reported that his mother said to the Prophet : “O Messenger of Allah! Anas is your servant, so please invoke for Allah's blessings for him.” The Prophet said: “O Allah! Increase his wealth and offspring and bless (for him) whatever You give him.”
Once a child of Abu Talha died; he became very sad and informed the Prophet about his death. The Prophet said to him, "Did you sleep with your wife last night? Abu Talha said: “Yes.” The Prophet said: “O Allah! Bestow your blessing on them.” Then His wife gave birth to a boy.
All the above details emphasize that supplicating is the best and most successful means to get offspring. Even though, one may take the possible material means for that purpose, as they are never contrary to supplicating Allah.
However, supplication is an important means. The best Du'aa’ is what is mentioned in the Quran or made by the Prophet as mentioned above.
Know, sincerity in making Du'aa’ for offspring is very necessary. One should ask for children with the intention that they will assist both in worldly and religious matters, to make Du'aa’ for him after his death and to give birth to those who will worship Allah.
Moreover, you should not despair of Mercy of Allah; Allah is Almighty, and every matter is in His Hands. He Granted a child named Ishaq to the Prophet Ibraheem (Abraham) while he was very aged and his wife was barren. Allah Says (what means): {And his Wife was standing, and she smiled. Then We gave her good tidings of Isaac and after Isaac, Jacob. She said, "Woe to me! Shall I give birth while I am an old woman and this, my husband, is an old man? Indeed, this is an amazing thing!"} [Quran 11: 71-72]
Allah also Says (what means): {And his wife approached with a cry [of alarm] and struck her face and said, "[I am] a barren old woman!"} [Quran 51: 29]
The same thing happened to the Prophet Zakariyyah .
Allah knows best.