WordPress.org

Make WordPress Core

Ticket #17134: 17134.2.diff

File 17134.2.diff, 1011 bytes (added by iandunn, 2 years ago)
  • wp-includes/post-template.php

     
    119119} 
    120120 
    121121/** 
     122 * Retrieve the slug of the current post in the WordPress Loop, or an arbitrary post. 
     123 * 
     124 * @since  
     125 *  
     126 * @uses $post 
     127 * @param int $id Optional. ID of an arbitrary post. If none is given, uses the value of the current post inside the Loop  
     128 * @return string|false String if post slug was retrieved, or false if it wasn't 
     129 */ 
     130function get_the_slug( $id = 0 ) { 
     131        global $post; 
     132                         
     133        if( $id ) { 
     134                $arbitrary_post = get_post( $id ); 
     135                $slug = is_a( $arbitrary_post, 'WP_Post' ) ? $arbitrary_post->post_name : false; 
     136        } else { 
     137                $slug = isset( $post->post_name ) ? $post->post_name : false; 
     138        } 
     139         
     140        return $slug; 
     141} 
     142 
     143/** 
    122144 * Display the Post Global Unique Identifier (guid). 
    123145 * 
    124146 * The guid will appear to be a link, but should not be used as an link to the