Get Tag Slug in single.php (5 posts)

  1. gamerusage01
    Posted 3 years ago #

    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.

  2. IMICreation
    Posted 3 years ago #

    <?php $tags = get_the_tags(get_the_id()); foreach($tags as $tag) { echo $tag->slug; } ?>
    put this code in your loop

  3. gamerusage01
    Posted 3 years ago #

    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 '.

  4. gamerusage01
    Posted 3 years ago #

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

  5. gamerusage01
    Posted 3 years ago #

    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(); ?>

Topic Closed

This topic has been closed to new replies.

About this Topic