From 8889ba6a683685515e02f6549cf949e403d0f05b Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Wed, 24 Sep 2014 21:30:19 +0000 Subject: [PATCH] Create correct permalinks for child posts of hierarchical post types when default permalinks are used. props loushou. fixes #29615 for trunk. Built from https://develop.svn.wordpress.org/trunk@29765 git-svn-id: http://core.svn.wordpress.org/trunk@29537 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/link-template.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/wp-includes/link-template.php b/wp-includes/link-template.php index 7a7b7874ed..13a74aa92a 100644 --- a/wp-includes/link-template.php +++ b/wp-includes/link-template.php @@ -257,10 +257,12 @@ function get_post_permalink( $id = 0, $leavename = false, $sample = false ) { $post_type = get_post_type_object($post->post_type); + if ( $post_type->hierarchical ) { + $slug = get_page_uri( $id ); + } + if ( !empty($post_link) && ( !$draft_or_pending || $sample ) ) { if ( ! $leavename ) { - if ( $post_type->hierarchical ) - $slug = get_page_uri($id); $post_link = str_replace("%$post->post_type%", $slug, $post_link); } $post_link = home_url( user_trailingslashit($post_link) );