| | 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 | */ |
| | 130 | function 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 | /** |