Make WordPress Core

Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#28611 closed defect (bug) (fixed)

Duplicate slug causes multiple posts to be displayed in single post template

Reported by: sergeybiryukov's profile SergeyBiryukov Owned by:
Milestone: 4.0 Priority: normal
Severity: normal Version: 3.0
Component: Query Keywords: has-patch
Focuses: Cc:


This is very similar to #22902, but affects hierarchical post types. See #meta523.

Steps to reproduce:

  1. Create a hierarchical CPT, e.g. "handbook".
  2. Add a top-level post called "Getting Started".
  3. Add another top-level post called "Contributing to the WordPress Codex".
  4. Add a third post called "Getting Started" and select the previous post as a parent.
  5. You should get this structure as a result:
  6. Now go to /handbook/getting-started/. Instead of just a top-level "Getting Started" post, you'll see two posts with the same title displayed in single.php template.

Has been this way since [13774].

WP_Query has an assumption that a top-level post of a hierarchical CPT can use name query var. However, we don't check for duplicate slugs in this case. Looks like hierarchical post types should always use pagename.

Attachments (1)

28611.patch (2.0 KB) - added by SergeyBiryukov 10 years ago.

Download all attachments as: .zip

Change History (3)

#1 @SergeyBiryukov
10 years ago

  • Resolution set to fixed
  • Status changed from new to closed

Fixed in [28803].

#2 @SergeyBiryukov
10 years ago

In 28809:

Use assertCount() for consistency with other tests.

see #28611.

Note: See TracTickets for help on using tickets.