Posts, Post Types: Don't add a trailing number when there is a unique post parent.

WordPress tries to avoid an issue where slugs might match an existing slug of a page/post. 
If we are in a hierarchical post type, there will be a level, and we can leave it the same.

Props stormrockwell, SergeyBiryukov, terriann, tubys, jeremyfelt, Daschmi, MaximeCulea, knutsp, whyisjake.
Fixes #51147.
See also #44112 and #45260.


git-svn-id: https://develop.svn.wordpress.org/trunk@51855 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Jake Spurlock
2021-09-23 20:26:28 +00:00
parent 36ed6d5107
commit 5bc2752524
2 changed files with 85 additions and 0 deletions

View File

@@ -736,6 +736,9 @@ function avoid_blog_page_permalink_collision( $data, $postarr ) {
if ( ! is_main_site() ) {
return $data;
}
if ( isset( $data['post_parent'] ) && $data['post_parent'] ) {
return $data;
}
$post_name = $data['post_name'];
$c = 0;