• Resolved cognitions

    (@cognitions)


    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.

Viewing 2 replies - 1 through 2 (of 2 total)
  • <?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

    Thread Starter cognitions

    (@cognitions)

    Thank you very much indeed! It works perfectly.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to echo current tag slug’ is closed to new replies.