[wp-trac] [WordPress Trac] #23351: Add the_slug() and get_the_slug()

WordPress Trac noreply at wordpress.org
Fri Feb 1 02:31:17 UTC 2013


#23351: Add the_slug() and get_the_slug()
-----------------------------+-------------------------
 Reporter:  iandunn          |       Type:  enhancement
   Status:  new              |   Priority:  normal
Milestone:  Awaiting Review  |  Component:  Post Types
  Version:  3.5              |   Severity:  normal
 Keywords:  needs-codex      |
-----------------------------+-------------------------
 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
 ([http://www.tcbarrett.com/2011/09/wordpress-the_slug-get-post-slug-
 function/ 1], [http://www.wprecipes.com/wordpress-function-to-get-
 postpage-slug 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:

 1. 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.
 2. Make the new functions pluggable, so they'd only be declared if others
 didn't already exist.
 3. 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.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/23351>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list