Skip to content

Instantly share code, notes, and snippets.

@greglinch
Created December 5, 2012 04:28
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save greglinch/4212235 to your computer and use it in GitHub Desktop.
Save greglinch/4212235 to your computer and use it in GitHub Desktop.
create the_slug() function for WordPress
function the_slug($echo=true){
$slug = basename(get_permalink());
do_action('before_slug', $slug);
$slug = apply_filters('slug_filter', $slug);
if( $echo ) echo $slug;
do_action('after_slug', $slug);
return $slug;
}
// credit: http://www.tcbarrett.com/2011/09/wordpress-the_slug-get-post-slug-function/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment