Caution: Translations of Quran and Ḥadīth may lead to possible misapplications and misinterpretations. This site is intended for students of sacred knowledge that are proficient in comprehending classical Arabic and have a strong foundation in Islamic sciences. Also note that religious injunctions rely on several aspects beyond what one may glean through reading individual aḥādīth.
quran:6:140

Those will have lost who killed their children in foolishness without knowledge and prohibited what Allah had provided for them, inventing untruth about Allah. They have gone astray and were not ˹rightly˺ guided.  

They are losers who slay (read qatalū or qattalū) their children, by burying them alive, in folly, out of ignorance, without knowledge, and have forbidden what God has provided them, of what has been mentioned, in calumny against God. Verily they have gone astray and are not guided.
القرآن:٦:١٤٠

قَدْ خَسِرَ الَّذِينَ قَتَلُوا أَوْلَادَهُمْ سَفَهًا بِغَيْرِ عِلْمٍ وَحَرَّمُوا مَا رَزَقَهُمُ اللَّهُ افْتِرَاءً عَلَى اللَّهِ ۚ قَدْ ضَلُّوا وَمَا كَانُوا مُهْتَدِينَ  

{قد خسر الذين قتلوا} بالتخفيف والتشديد {أولادهم} بالوأد {سفها} جهلا {بغير علم وحرَّموا ما رزقهم الله} مما ذكر {افتراء على الله قد ضلوا وما كانوا مهتدين}.