[wp-trac] [WordPress Trac] #64670: WP_REST_Posts_Controller::update_item() not passing parent to wp_unique_post_slug() for draft child

WordPress Trac noreply at wordpress.org
Wed Feb 18 18:47:10 UTC 2026


#64670: WP_REST_Posts_Controller::update_item() not passing parent to
wp_unique_post_slug() for draft child
-------------------------------+-------------------------------------------
 Reporter:  esaner             |       Owner:  (none)
     Type:  defect (bug)       |      Status:  new
 Priority:  normal             |   Milestone:  Awaiting Review
Component:  REST API           |     Version:  6.9.1
 Severity:  normal             |  Resolution:
 Keywords:  has-patch needs-   |     Focuses:  ui, administration, rest-api
  testing                      |
-------------------------------+-------------------------------------------
Changes (by maulikmakwana2008):

 * keywords:  has-patch => has-patch needs-testing
 * component:  Permalinks => REST API


Comment:

 I’ve prepared a fix that preserves the existing parent ID when updating
 draft hierarchical posts via the REST API.

 Currently, when post_parent is not included in the REST request (as in the
 block editor for draft child pages), wp_unique_post_slug() is called with
 a parent ID of 0, causing false slug conflicts with top-level posts.

 The patch falls back to $post_before->post_parent when $post->post_parent
 is empty, ensuring slug uniqueness is evaluated using the correct parent.
 This aligns block editor behavior with Quick Edit and classic update
 flows.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/64670#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list