Opened 12 months ago
Last modified 5 weeks ago
#20861 reopened defect (bug)
switch_to_blog() breaks custom post type permalinks — at Version 1
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | Awaiting Review |
| Component: | Multisite | Version: | |
| Severity: | normal | Keywords: | |
| Cc: | jaroat, ryan@…, brad@…, info@… |
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
Note: See
TracTickets for help on using
tickets.
