switch_to_blog() breaks custom post type permalinks
|Reported by:||sickhippie||Owned by:|
Description (last modified by SergeyBiryukov)
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
Change History (13)
4 years ago
- Milestone Awaiting Review deleted
- Resolution set to invalid
- Status changed from new to closed
- Cc jaroat added
- Resolution worksforme deleted
- Status changed from closed to reopened
- Version 3.3.2 deleted