diff --git a/wp-includes/post.php b/wp-includes/post.php index 8d649db19..a7ba42333 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -4024,8 +4024,9 @@ function wp_check_for_changed_slugs($post_id, $post, $post_before) { if ( $post->post_name == $post_before->post_name ) return; - // we're only concerned with published objects - if ( $post->post_status != 'publish' ) + // we're only concerned with published, non-hierarchical objects + $ptype_obj = get_post_type_object( $post->post_type ); + if ( $post->post_status != 'publish' || !$ptype_obj || $ptype_obj->hierarchical ) return; $old_slugs = (array) get_post_meta($post_id, '_wp_old_slug'); diff --git a/wp-includes/query.php b/wp-includes/query.php index e38c2dbab..51f9bd191 100644 --- a/wp-includes/query.php +++ b/wp-includes/query.php @@ -3231,6 +3231,11 @@ function wp_old_slug_redirect() { else $post_type = 'post'; + // Do not attempt redirect for hierarchical post types + $ptype_obj = get_post_type_object( $post_type ); + if ( !$ptype_obj || $ptype_obj->hierarchical ) + return; + $query = $wpdb->prepare("SELECT post_id FROM $wpdb->postmeta, $wpdb->posts WHERE ID = post_id AND post_type = %s AND meta_key = '_wp_old_slug' AND meta_value = %s", $post_type, $wp_query->query_vars['name']); // if year, monthnum, or day have been specified, make our query more precise