[wp-trac] [WordPress Trac] #36465: Implement get_content_id_by_slug() function

WordPress Trac noreply at wordpress.org
Sun Apr 10 15:30:33 UTC 2016


#36465: Implement get_content_id_by_slug() function
--------------------------------------+-----------------------------
 Reporter:  eclare                    |      Owner:
     Type:  feature request           |     Status:  new
 Priority:  normal                    |  Milestone:  Awaiting Review
Component:  Posts, Post Types         |    Version:
 Severity:  normal                    |   Keywords:
  Focuses:  administration, template  |
--------------------------------------+-----------------------------
 Sometimes theme & plugin creators have a need to get the ID of any content
 type (usually a page) by its slug. Aside from use cases where developers
 prefer to hardcode slugs rather than IDs themselves (which seems better),
 this could also be used to detect and set some default values, for
 example: finding the contact page (slug: contact, contact-us, contact-2),
 home page etc...

 This currently requires a few lines of code, posted here:
 https://gist.github.com/eddt/ee1018f26f8fc195629a (not sure if it would
 work with child theme slugs without parent slugs).

 This could be in the core as get_content_id_by_slug() or similarly named
 function.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/36465>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list