Perhaps this is a scoping issue. Or wrong template setup.
I suggest you follow and try:
And maybe show more of your code?