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
This commit is contained in:
Sergey Biryukov 2014-09-24 21:30:19 +00:00
parent 10e0807cce
commit 8889ba6a68

View File

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