The verse “And the poets it is those straying in evil who follow them. He (Allah) then abrogated it and made an exception saying: Except those who believe and work righteousness, engage much in the remembrance of Allah." (Using translation from Abū Dāʾūd 5016)
{وَالشُّعَرَاءُ يَتَّبِعُهُمُ الْغَاوُونَ} [الشعراء 224] فَنَسَخَ مِنْ ذَلِكَ وَاسْتَثْنَى فَقَالَ {إِلَّا الَّذِينَ آمَنُوا وَعَمِلُوا الصَّالِحَاتِ وَذَكَرُوا اللهَ كَثِيرًا} [الشعراء 227]