Ironically, this issue has come up before in almost the exact same context...
The result/decision/advice:
*Change the way you are doing things...
In other words, figure out your content (or at least the title) prior to calling for it in your script/template: You have to assign their value prior to using them... No ifs ands or buts.