Thanks for getting back to me. Yes, deactivating works but as mentioned, this exact code works on my old site (which is still running on https://www.ssbm-online.co.uk/oldsite/) without a problem.
I tried running a cache plugin and it makes no difference.