Added check in case somehow $post isn't an object

Apparently, it can happen.