Trying to get property of non-object when using get_post_permalink()

The reason that it’s an issue is because I’m using switch_to_blog() on a multisite. The post_type doesn’t exist on the current blog. It exists only on the main blog. Since the post_type doesn’t exist, the get_post_type_object() function is returning null.

What I did to fix this is create a custom_get_post_permalink function that also takes a blog_id argument and therefore changes to the appropriate blog_id on the multisite to create the post_type_object correctly.