[wp-trac] [WordPress Trac] #28611: Duplicate slug causes multiple posts to be displayed in single post template

WordPress Trac noreply at wordpress.org
Sun Jun 22 02:18:58 UTC 2014


#28611: Duplicate slug causes multiple posts to be displayed in single post
template
----------------------------+-----------------------
 Reporter:  SergeyBiryukov  |      Owner:
     Type:  defect (bug)    |     Status:  new
 Priority:  normal          |  Milestone:  4.0
Component:  Query           |    Version:  3.0
 Severity:  normal          |   Keywords:  has-patch
  Focuses:                  |
----------------------------+-----------------------
 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:
 {{{
 /handbook/getting-started/
 /handbook/contributing-to-the-wordpress-codex/
 /handbook/contributing-to-the-wordpress-codex/getting-started/
 }}}
 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` [source:tags/3.9.1/src/wp-includes/query.php#L2368 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`.

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


More information about the wp-trac mailing list