Fix Notice: Trying to get property of non-object

Was getting this notice on a single post page. This got rid of the warning for me.