diff --git a/src/wp-includes/post.php b/src/wp-includes/post.php
index 2a02400bd1..3042ec7ddc 100644
a
|
b
|
function wp_unique_post_slug( $slug, $post_id, $post_status, $post_type, $post_p |
5165 | 5165 | * Page slugs must be unique within their own trees. Pages are in a separate |
5166 | 5166 | * namespace than posts so page slugs are allowed to overlap post slugs. |
5167 | 5167 | */ |
5168 | | $check_sql = "SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND post_type IN ( %s, 'attachment' ) AND ID != %d AND post_parent = %d LIMIT 1"; |
| 5168 | if ( 'page' === $post_type ) { |
| 5169 | $check_sql = "SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND post_type IN ( %s, 'post', 'attachment' ) AND ID != %d AND post_parent = %d LIMIT 1"; |
| 5170 | } else { |
| 5171 | $check_sql = "SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND post_type IN ( %s, 'attachment' ) AND ID != %d AND post_parent = %d LIMIT 1"; |
| 5172 | } |
5169 | 5173 | $post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $slug, $post_type, $post_id, $post_parent ) ); |
5170 | 5174 | |
5171 | 5175 | /** |
… |
… |
function wp_unique_post_slug( $slug, $post_id, $post_status, $post_type, $post_p |
5195 | 5199 | } |
5196 | 5200 | } else { |
5197 | 5201 | // Post slugs must be unique across all posts. |
5198 | | $check_sql = "SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND post_type = %s AND ID != %d LIMIT 1"; |
| 5202 | if ( 'post' === $post_type ) { |
| 5203 | $check_sql = "SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND post_type IN( %s, 'page' ) AND ID != %d LIMIT 1"; |
| 5204 | } else { |
| 5205 | $check_sql = "SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND post_type = %s AND ID != %d LIMIT 1"; |
| 5206 | } |
5199 | 5207 | $post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $slug, $post_type, $post_id ) ); |
5200 | 5208 | |
5201 | 5209 | $post = get_post( $post_id ); |