Skip to content

Instantly share code, notes, and snippets.

@raphaelchaib
Last active December 15, 2015 06:09
Show Gist options
  • Save raphaelchaib/5213805 to your computer and use it in GitHub Desktop.
Save raphaelchaib/5213805 to your computer and use it in GitHub Desktop.
Wordpress: Get post slug
<?php
// Return post's slug
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;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment