Support » Fixing WordPress » Get Tag Slug in single.php

  • I am pulling my hair on this one, hopefully someone can help me.

    I have looked everywhere and can not find a function/get that will grab the tag slug of the current post I am viewing.

    The reason why I need this is because I have content in tabs that will get loaded on tags.


    I currently have on tag on a post. I want to grab the tag slug (Tag would be called The: Show and the slug would be the-show.

    The slug is what I need. Thanks for your help.

Viewing 4 replies - 1 through 4 (of 4 total)
  • <?php $tags = get_the_tags(get_the_id()); foreach($tags as $tag) { echo $tag->slug; } ?>
    put this code in your loop

    Code works great. Only problem is that the code will be going into a <?php function so it needs to be converted.

    I don’t know the exact way/term but it involves removing the <?php and the ?> being replaced by .’ and ‘.

    should note that this will be going in the query_posts function (tag= specifically)

    never mind. I figured it out. For those that want to know for future cases:

    <?php $tags = get_the_tags(get_the_id()); foreach($tags as $tag) ?>
    <?php query_posts('cat=23&tag='.$tag->slug.'&showposts=3&posts_per_page=3&paged=' . get_query_var('paged') ); while (have_posts()) : the_post(); ?>
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Get Tag Slug in single.php’ is closed to new replies.