Skip to content

Instantly share code, notes, and snippets.

@CEscorcio
Created August 1, 2013 11:59
Show Gist options
  • Save CEscorcio/6130720 to your computer and use it in GitHub Desktop.
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
/************* 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