[wp-trac] [WordPress Trac] #20861: switch_to_blog() breaks custom post type permalinks

WordPress Trac noreply at wordpress.org
Tue Nov 6 13:06:53 UTC 2012


#20861: switch_to_blog() breaks custom post type permalinks
--------------------------+------------------------------
 Reporter:  sickhippie    |       Owner:
     Type:  defect (bug)  |      Status:  reopened
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Multisite     |     Version:
 Severity:  normal        |  Resolution:
 Keywords:                |
--------------------------+------------------------------

Comment (by jaroat):

 Seems that get_permalink for custom post types depends on
 get_extra_permastruct in wp-includes/rewrite.php and acts wrongly if the
 target custom post types was registered with the "with_front" parameter
 (or without: with_front=1 is default).

 get_extra_permastruct relies on it's internal var extra_permastructs
 ['post-type-name'] which doesn't get updated to the new context when
 calling switch_to_blog.

 So all permalinks fetched after switch_to_blog get constructed in the
 rewrite-context of the original blog calling the function - not the blog
 context the programmer switched to.


 br from Salzburg,

 - Johannes

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/20861#comment:7>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list