[wp-trac] [WordPress Trac] #53346: get_permalink( $post->ID ) returns plain permalink instead of pretty permalink for CPT registered on subsite

WordPress Trac noreply at wordpress.org
Mon Jun 7 11:09:34 UTC 2021


#53346: get_permalink( $post->ID ) returns plain permalink instead of pretty
permalink for CPT registered on subsite
--------------------------+------------------------------
 Reporter:  1theo         |       Owner:  (none)
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Permalinks    |     Version:  5.7
 Severity:  normal        |  Resolution:
 Keywords:                |     Focuses:  multisite
--------------------------+------------------------------
Changes (by SergeyBiryukov):

 * focuses:   => multisite


Old description:

> I have a multisite network with CPTs that are registered individually by
> subsite.
> The main site provides an overview of these, using
> {{{
> get_permalink( $post->ID );
> }}}
>  to link to the pretty permalink location in each subsite.
>
> After the introduction of
> {{{
> wp_force_plain_post_permalink()
> }}}
> in WP 5.7.0
>
> https://core.trac.wordpress.org/ticket/52373
> https://core.trac.wordpress.org/ticket/5272
>

> **get_permalink()** returns plain permalinks due to failing to pass the
> test in **wp_force_plain_post_permalink()**:
>

> {{{
>         $post_type_obj   = get_post_type_object( get_post_type( $post )
> );
> }}}
>
> **get_post_type_object()** returns null, as the CPT is not present in the
> global **$wp_post_types** of the main site (even after trying
> switch_to_blog( $post->blog_id );

New description:

 I have a multisite network with CPTs that are registered individually by
 subsite.
 The main site provides an overview of these, using
 {{{
 get_permalink( $post->ID );
 }}}
 to link to the pretty permalink location in each subsite.

 After the introduction of
 {{{
 wp_force_plain_post_permalink()
 }}}
 in WP 5.7.0

 #52373 #5272


 **get_permalink()** returns plain permalinks due to failing to pass the
 test in **wp_force_plain_post_permalink()**:


 {{{
         $post_type_obj   = get_post_type_object( get_post_type( $post ) );
 }}}

 **get_post_type_object()** returns null, as the CPT is not present in the
 global **$wp_post_types** of the main site (even after trying
 switch_to_blog( $post->blog_id );

--

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/53346#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list