Make WordPress Core

Opened 3 years ago

Last modified 3 years ago

#53346 new defect (bug)

get_permalink( $post->ID ) returns plain permalink instead of pretty permalink for CPT registered on subsite

Reported by: 1theo's profile 1theo Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 5.7
Component: Permalinks Keywords:
Focuses: multisite Cc:

Description (last modified by SergeyBiryukov)

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 );

Change History (1)

#1 @SergeyBiryukov
3 years ago

  • Description modified (diff)
  • Focuses multisite added
Note: See TracTickets for help on using tickets.