Skip to content

Instantly share code, notes, and snippets.

@ki11ua
Forked from greglinch/the_slug.php
Created February 13, 2018 08:55
Show Gist options
  • Save ki11ua/b070c274c9fb20996270c473409753cb to your computer and use it in GitHub Desktop.
Save ki11ua/b070c274c9fb20996270c473409753cb 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