The thing is I’ve got the same code working on another wordpress website which uses a different theme. So it has to be theme related. I was just wondering if anyone had come across this issue or similar before.
It really is odd.
I’ve tried putting the code snippet into the actual template file also but that didn’t work either.