#23351 closed feature request (duplicate)
Add the_slug() and get_the_slug()
Reported by: | iandunn | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | |
Component: | Template | Keywords: | |
Focuses: | Cc: |
Description
It's not uncommon for a theme or plugin to want to use a post's slug, but the API doesn't provided a function for accessing it. There are several homegrown functions online that people are using (1, 2), but some of them are buggy or poorly written, and it seems like this is something the API should provide a consistent mechanism for accessing, just like it does for the other properties of a post.
Many of the homegrown methods didn't prefix their functions names, so there would be collisions for them if this were committed to a future release. Here are a couple ideas for addressing that:
- Choose different names to avoid collisions. The downside here is that the new function names wouldn't be consistent with similar functions like the_title(), the_guid(), etc.
- Make the new functions pluggable, so they'd only be declared if others didn't already exist.
- Just let collisions happen. The error PHP spits out is fairly descriptive, so it shouldn't be too hard for people to realize what's going on.
I'm leaning towards #3, but would like to hear other opinions.
I assumed there'd already be a ticket for this, but couldn't find one. If anyone knows of another, please mark this as a duplicate.
Er, nevermind, just found #17134. Closing this one.