Hi @agilepixel
Can you try removing blocks of code from your template until the issue goes away?
At what line does the issue start?
This will show exactly what the issue is coming from.
Also, are you using the setup_postdata on an autosave post or non published post?