WordPress.org

Make WordPress Core

Opened 3 months ago

Last modified 3 months ago

#52422 new defect (bug)

Create a draft with the same slug as an existing post, the existing post will be 404.

Reported by: Toro_Unit Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: General Keywords: needs-patch
Focuses: Cc:

Description

Step-by-step reproduction instructions

  1. create custom post type. and set 'show_in_rest' => true
<?php
function custom_init() {
        $args = array(
                'public' => true,
                'label'  => 'Books',
                'show_in_rest' => true,
        );
        register_post_type( 'book', $args );
}
add_action( 'init', 'custom_init' );
  1. Publish new post of the post type.
  2. Create draft post of the post type with same slug.
  3. Go to the published post. but show draft post. if logged out, 404.

Using the block editor, a page can also create drafts with the same slug, which causes the same problem.

Attachments (2)

issue.gif (2.1 MB) - added by Toro_Unit 3 months ago.
A gif animation of the issue.
issue-on-page.gif (4.3 MB) - added by Toro_Unit 3 months ago.
reproduced on page.

Change History (5)

#1 @h2ham
3 months ago

It also happened in default posts.

  1. Set permalink to %postname%.
  2. Publish new post of default posts.
  3. Create draft post of the default post with same slug.
  4. Go to the published post. but show draft post. If logged out, 404.

#2 @peterwilsoncc
3 months ago

I've attempted to reproduce this on both 5.6 and trunk without success. I've tried with both a CPT per the original post and standard posts per the follow up comment.

Are either of you able to reproduce this with all plugins disabled and using a default theme such as Twenty Twenty-One?

#3 @Toro_Unit
3 months ago

@peterwilsoncc Thanks.

No plugins are used, and the theme is Twenty Twenty One. reproduced on WordPress 5.5 and 5.6.

When creating a post, please use the block editor.
Quick Edit or Classic Editor don't allow us to create a post with the same slug as an existing post.

@Toro_Unit
3 months ago

A gif animation of the issue.

@Toro_Unit
3 months ago

reproduced on page.

Note: See TracTickets for help on using tickets.