Created
August 1, 2013 11:59
-
-
Save CEscorcio/6130720 to your computer and use it in GitHub Desktop.
/************* Display the page or post slug *****************/
Just use get_slug() Use this in Functions.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/************* Display the page or post slug *****************/ | |
function get_the_slug( $id=null ){ | |
if( empty($id) ): | |
global $post; | |
if( empty($post) ) | |
return ''; // No global $post var available. | |
$id = $post->ID; | |
endif; | |
$slug = basename( get_permalink($id) ); | |
return $slug; | |
} | |
function the_slug( $id=null ){ | |
echo apply_filters( 'the_slug', get_the_slug($id) ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment