Last active
March 22, 2017 19:06
-
-
Save tinotriste/5388189 to your computer and use it in GitHub Desktop.
Wordpress: Get post/page slug
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
<?php | |
// Custom function to return the post 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; | |
} | |
?> |
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
<?php if (function_exists('the_slug')) { the_slug(); } ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment