Check get_post_type_object() returns an object before using it