WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 4 years ago

#33956 closed enhancement (duplicate)

New function: `get_the_slug()`

Reported by: sebastian.pisula Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Posts, Post Types Keywords: has-patch reporter-feedback
Focuses: Cc:

Description

Function to display post slug

Attachments (2)

33956.patch (46.3 KB) - added by sebastian.pisula 4 years ago.
339561.patch (854 bytes) - added by sebastian.pisula 4 years ago.

Download all attachments as: .zip

Change History (6)

#1 @swissspidy
4 years ago

  • Keywords has-patch needs-refresh needs-unit-tests added

Thanks for the patch!

Just some notes:

  • Brackets shouldn't be on the new line
  • It should be possible to pass a WP_Post object and not only an ID
  • Lacks some more documentation, especially for the filter
  • You got some IntelliJ/PhpStorm headers in your diff. Try to remove those
  • Core uses slugs at many points, why not use this new function there?

See https://make.wordpress.org/core/handbook/best-practices/coding-standards/php/ and https://make.wordpress.org/core/handbook/best-practices/inline-documentation-standards/php/

It's worth noting that many people implemented their own the_slug functions over the years so this might break some sites.

#2 @helen
4 years ago

Could you kindly describe your use case? It's preferable to focus on the problem/need you're trying to solve for rather than solution-first.

#3 @johnbillion
4 years ago

  • Keywords reporter-feedback added; needs-refresh needs-unit-tests removed

#4 @wonderboymusic
4 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.