switch_to_blog() breaks custom post type permalinks — at Initial Version
|Reported by:||sickhippie||Owned by:|
When using switch_to_blog() and custom post types, there are very strange results when calling the_permalink() or get_permalink(). For reference, we'll say the root site is blog1 and the second site containing the posts is blog2.
Using this code inside the loop:
switch_to_blog( $post->blog_id ); get_permalink();
If the post type is not registered on the current blog, the permalink given will be sitename.com/blog2/slug - when clicking it as href, it brings you the first instance of that slug in the database.
If the post type is registered on the current blog, the permalink given will be sitename.com/blog2/blog1/post-type/slug - this link will 404.
Related issue: 14992