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, sallallaahu ‘alayhi wa sallam, is His slave and Messenger.
Wisdom means the perfection of knowledge and acting according to knowledge. It is a gift that Allaah Grants to whomever He Wills of His slaves. Scholars held different opinions about the meaning of 'wisdom' that is mentioned in the part of verse (which means): {He Gives wisdom to whom He Wills…}[Quran 2:269] It was said that it is Prophethood. Ibn ‘Abbaas said that it is the knowledge of the Quran, the abrogating and the abrogated verses, precise and unspecific verses, meanings of and rhetoric used in verses. Anas ibn Maalik said, “Wisdom means knowing the Religion of Allaah, understanding it and following it.” Other scholars interpreted wisdom as fearing Allaah Almighty.
Ibn ‘Aashoor said, “Allaah Mentioned 'wisdom' in many places of His Book, Referring to what reforms souls of Prophethood and guidance.”
Considering these and other sayings, we find that 'wisdom' from the Sharee‘ah perspective mainly revolves around religious matters such as fearing Allaah, and knowing the Quran and the Sunnah of the Messenger of Allaah, sallallaahu ‘alayhi wa sallam, who said: “When Allaah Wants good for someone, He Makes him understand religion.” [Al-Bukhari and Muslim] However, worldly sciences may also be included if they are useful to the Ummah, such as the benefit derived from the science of medicine if it is sought for the Sake of Allaah.
We did not come across the Hadeeth that you have mentioned. However, some of its words were narrated by Al-Bayhaqi on the authority of the Prophet, sallallaahu ‘alayhi wa sallam, who said: "Indeed, Allaah Gives the world to whom He Likes and to whom He Does not Like, but He Does not give religion except to whom He Likes."