[wp-trac] [WordPress Trac] #54571: Creating post via REST API with custom slug and "publish" status appends "-2" to slug

WordPress Trac noreply at wordpress.org
Fri Dec 3 16:41:12 UTC 2021


#54571: Creating post via REST API with custom slug and "publish" status appends
"-2" to slug
-----------------------------+-----------------------------
 Reporter:  markus.magnuson  |      Owner:  (none)
     Type:  defect (bug)     |     Status:  new
 Priority:  normal           |  Milestone:  Awaiting Review
Component:  General          |    Version:  5.8.2
 Severity:  normal           |   Keywords:
  Focuses:  rest-api         |
-----------------------------+-----------------------------
 I'm trying to create a new post via the REST API (using a Python script).
 There are no existing posts, not even in the trash. If I create the post
 using this data:


 {{{
 post = {
     "title": "test title",
     "content": "test content",
     "slug": "001",
     "status": "publish",
     "tags": [3],
 }
 }}}


 It gets assigned the slug "001-2" which cannot even be edited afterwards.
 It's like there's some ghost post claiming the desired slug.

 If I change the post data to not publish the post:


 {{{
 post = {
     "title": "test title",
     "content": "test content",
     "slug": "001",
     "tags": [3],
 }
 }}}


 It gets the correct "001" slug.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/54571>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list