Do what single_term_title
does and check the queried object with get_queried_object
.
function single_tax_slug() {
$term = get_queried_object();
if ( !$term )
return;
if ( is_category() ) {
$term_slug = $term->slug;
} elseif ( is_tag() ) {
$term_slug = $term->slug;
} elseif ( is_tax() ) {
$term_slug = $term->slug;
}
return $term_slug;
}
$slug = single_tax_slug();
var_dump($slug);
If you look at that code, it is basically the first few lines of single_term_title
, simplified considerably, and altered to get the slug.