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.
If it is possible to reconcile between two seemingly contradictory texts, then reconciliation between them is to be given precedence over abrogating (which is to adopt one and reject the other) because reconciliation between the texts means considering the two reports and adopting both. Al-Haafith Ibn Hajar said, "Reconciling between the two texts is preferable to adopting one and rejecting another (after examining the soundness of both), according to the consensus of the scholars of Usool Al-Fiqh (principles of jurisprudence)." It is well known that abrogation or giving preponderance entails rejecting one of the texts.
There is no doubt that the hadeeth refers to the Hereafter. Based on the view that the verse is interpreted as to refer to the hereafter, Ibn Taymiyyah wrote:
"It is a negation of his knowledge of all that shall happen to him and to people in the Hereafter; only Allaah possesses knowledge of that. This does not negate that he (the Prophet ) knew that he shall be blessed among the inhabitants of Paradise, even if he did not know the details of what happens to him in the world, the tribulations that befall him, the religious provisions revealed to him, and the pleasures of Paradise awaiting him in the hereafter. It has been reported that the Prophet said, 'Allaah, the Exalted, has said, 'I have prepared for my righteous slaves what no eye has seen, no ear has heard, and the mind of no man has conceived.'' This fact has been stated by other Prophets of Allaah, may Allaah exalt their mention, as well. It is also not a condition that the Prophet knew the state of the addressees with regard to who would believe and who would disbelieve and their destination in the Hereafter in detail..."
The verse may possibly be interpreted as to refer to the hereafter, and the intended meaning would be knowing the details of what shall happen to them and to him . The hadeeth applies to children; scholars held different views in this regard, contrary to the case with the adult disbelievers; as the general indication of the relevant texts suggests that whoever received the message of Islam and rejected it shall abide eternally in Hellfire.
Allaah knows best.