Make WordPress Core

Opened 6 months ago

Last modified 6 months ago

#43001 new defect (bug)

Page Slug and Attachment - Conflict

Reported by: sebastian.pisula Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: trunk
Component: Posts, Post Types Keywords: has-patch
Focuses: Cc:


I found problem. My attachment have post_name "test" and I want set for my new page post_name "test" and WordPress generate "test-2". I think that problem is with wp_unique_post_slug function in file: wp-includes/post.php:3950:

$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";

I attach fix

Attachments (1)

43001.patch (918 bytes) - added by sebastian.pisula 6 months ago.

Download all attachments as: .zip

Change History (3)

#1 @sebastian.pisula
6 months ago

  • Keywords has-patch added

#2 @swissspidy
6 months ago

Note that media items which aren't attached to a post can be accessed via example.com/my-attachment-slug/, hence this check within wp_unique_post_slug(). Your patch would break that behaviour.

Note: See TracTickets for help on using tickets.