The Messenger of Allah ﷺ said, "There are four whose rewards continue to flow to them after death. One who is stationed on guard in the cause of Allah, one who has done a deed for whom the like of that deed continues to be credited, one who gave a charity for whom its reward continues as long as it remains in use, and one who left behind a righteous child who supplicates for him."
حدثنا حسن حدثنا ابن لهيعة عن خالد بن أبي عمران
عن رسول الله ﷺ أنه قال أربعة تجري عليهم أجورهم بعد الموت مرابط في سبيل الله ومن عمل عملا أجري له مثل ما عمل ورجل تصدق بصدقة فأجرها له ما جرت ورجل ترك ولدا صالحا فهو يدعو له
Its isnad is hasan. Tabarani narrated the hadith in Al-Kabir 8/243 no. 7831, and Munziri graded it sahih in Targheeb 1/119.