cognitions
Member
Posted 4 years ago #
On a category.php the following works to echo the current category slug:
<?php
if (is_category()) {
$yourcat = get_category ($cat);
echo 'the slug is '.$yourcat->slug;
}
?>
Please could someone tell me how to modify this so that on tag.php I can echo the current tag slug. I have tried everything.
Thank you.
<?php
if ( is_tag() ) {
$term_id = get_query_var('tag_id');
$taxonomy = 'post_tag';
$args ='include=' . $term_id;
$terms = get_terms( $taxonomy, $args );
echo '<p> slug is ' . $terms[0]->slug . '</p>';
}
?>
Related:
Tag_Templates
cognitions
Member
Posted 4 years ago #
Thank you very much indeed! It works perfectly.