Created
June 8, 2013 19:43
-
-
Save nguyenvanduocit/5736349 to your computer and use it in GitHub Desktop.
Lấy slug của một term,
This file contains 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
function single_term_slug( $prefix = '', $display = true ) { | |
$term = get_queried_object(); | |
if ( !$term ) | |
return; | |
if ( is_category() ) | |
$term_slug = apply_filters( 'single_cat_slug', $term->slug ); | |
elseif ( is_tag() ) | |
$term_slug = apply_filters( 'single_tag_slug', $term->slug ); | |
elseif ( is_tax() ) | |
$term_slug = apply_filters( 'single_term_slug', $term->slug ); | |
else | |
return; | |
if ( empty( $term_slug ) ) | |
return; | |
if ( $display ) | |
echo $prefix . $term_slug; | |
else | |
return $term_slug; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment