Ticket #17134: 17134.2.diff

File 17134.2.diff, 1011 bytes (added by iandunn, 4 months ago)
Line 
1Index: wp-includes/post-template.php
2===================================================================
3--- wp-includes/post-template.php       (revision 23362)
4+++ wp-includes/post-template.php       (working copy)
5@@ -119,6 +119,28 @@
6 }
7 
8 /**
9+ * Retrieve the slug of the current post in the WordPress Loop, or an arbitrary post.
10+ *
11+ * @since
12+ *
13+ * @uses $post
14+ * @param int $id Optional. ID of an arbitrary post. If none is given, uses the value of the current post inside the Loop
15+ * @return string|false String if post slug was retrieved, or false if it wasn't
16+ */
17+function get_the_slug( $id = 0 ) {
18+       global $post;
19+                       
20+       if( $id ) {
21+               $arbitrary_post = get_post( $id );
22+               $slug = is_a( $arbitrary_post, 'WP_Post' ) ? $arbitrary_post->post_name : false;
23+       } else {
24+               $slug = isset( $post->post_name ) ? $post->post_name : false;
25+       }
26+       
27+       return $slug;
28+}
29+
30+/**
31  * Display the Post Global Unique Identifier (guid).
32  *
33  * The guid will appear to be a link, but should not be used as an link to the