It is possible that there has been some change on your site.
Have you done any plugin/theme update?
Kindly try deactivating all the plugins and revert to the default wordpress theme and let see if the code still works. It could be a plugin conflict.
Hope this helps.