[wp-trac] [WordPress Trac] #18962: Allow duplicate slugs for different content
WordPress Trac
noreply at wordpress.org
Thu May 23 21:11:49 UTC 2013
#18962: Allow duplicate slugs for different content
------------------------------+-----------------------------
Reporter: maorb | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Future Release
Component: Rewrite Rules | Version:
Severity: normal | Resolution:
Keywords: needs-unit-tests |
------------------------------+-----------------------------
Changes (by mboynes):
* cc: mboynes@… (added)
Comment:
Can someone please explain why `wp_unique_post_slug` works the way it does
with regards to hierarchical custom post types versus non-hierarchical
custom post types?
That is, if two custom post types have `'hierarchical'` set to `false`,
posts can share the same slug. However, if two custom post types have it
set to `true`, they cannot. This can be seen in
http://core.trac.wordpress.org/browser/trunk/wp-includes/post.php#L3036
where the hierarchical post types check:
`SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND post_type IN
( '" . implode( "', '", esc_sql( $hierarchical_post_types ) ) . "' ) ...`
(where `$hierarchical_post_types` is an array of all hierarchical post
types). By comparison, non-hierarchical post types check:
`SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND post_type =
%s ...`
(where post_type's `%s` is merely the current post's post type).
I'm sure that I'm missing something, but when I modify this to restrict
the hierarchical post types query to just the current post type,
everything ''appears'' to work just fine. Patch forthcoming.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/18962#comment:13>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list