[wp-hackers] Slug Fest

Barrett Golding bg at hearingvoices.com
Sat Jan 7 18:41:53 UTC 2012


dear hackers,
in writing a Codex Docs page on Naming Slugs.
i hope it's ok to consult this list on code-related questions.
(and thanks Otto for that feature/bug clarification)

i'm trying to clearly, concisely, & accurately explain when slugs get a "-2",
aka, the return value of wp_unique_post_slug(). 

Q1. that function has this comment:
 "// Page slugs must be unique within their own trees."

not sure if that's correct way to say it? i think the function checks
for identical post_name AND post_parent IN (any) hierarchical post_type
-- so it doesn't distinguish btwn trees.

here's some non-unique slugs in the same Page tree that DON'T get a "-2":
/pagename/pagename/pagename/

while top-level page slugs in different trees DO  get a "-2" (both: post_parent=0):
/pagename/ (Page)
/cpt-slug/pagename-2/  (CPT page)

so, am i correct in saying?:
All top-level parent page slugs (Pages and CPTs) must be unique.
All Page slugs (and hierarchical CPT page slugs) with the same parent page must be unique.

(i'll phase it better later for avg user, for now just want to know if i have it right).

Q2. comment reads:
"// Attachment slugs must be unique across all types."

this seems right, the SQL checks for thru all post_name(s), regardless of post_type.
so, am i correct in saying?:

Attachment slugs must be unique among all post types (including nav_menu).

bg
-- 
<http://HearingVoices.com/>
~radio active transmissions~



More information about the wp-hackers mailing list