Opened 11 years ago
Last modified 6 years ago
#28017 new defect (bug)
Slug conflict with hierarchical Custom Post Types
Reported by: | internetrnd | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 3.9 |
Component: | Posts, Post Types | Keywords: | needs-patch |
Focuses: | Cc: |
Description
To Replicate, create a hierarchical custom post type and make sure it has support for page attributes, lets call it "items"
Publish 3 "items" posts with the following slug and content ( IN THIS ORDER! )
Post 1: Slug - samsung , No Parent , content : "Welcome to Samsung"
Post 2: Slug - cell-phones , No Parent , content : "Welcome to cell phones"
Post 3: Slug - samsung , Parent: cell-phones , content : "Welcome to cell phones by Samsung"
Navigate to http://localhost/items/samsung/ , You will see the content for Post 3. The correct content should be from Post 1. http://localhost/items/cell-phones/samsung/ works just fine.
To get the correct results:
Modify wp-includes/query.php , line 2340:
// ORIGINAL LINE if ( ! $ptype_obj->hierarchical || strpos($q[ $ptype_obj->query_var ], '/') === false ) { // MODIFIED LINE if ( ! $ptype_obj->hierarchical ) {
I was able to reproduce this problem, but for me navigating to
/items/samsung/
displayed both Post 1 and Post 3 on the same page.Also I find that disabling permalinks sets the link of both Post 1 and 3 to
/?items=samsung
and accessing this link displays both of them.