Support » Plugins » Single instance of each tag in a category?

  • I’ve never seen code or a plugin which can show a single instance of each tag in a category. This code almost does it, but it only shows a list of the tags, and not the actual links to the tag archives. Does anyone know if it can be modified to show the actual tag links? I’ve tried a few things but my php is really limited.

    [Code moderated as per the Forum Rules. Please use the pastebin]

    I really need something which can do this, if anyone could help that would be great.

Viewing 1 replies (of 1 total)
  • Thread Starter deepbevel

    (@deepbevel)

    Sorry, my code didn’t make it in again:

    <?php
            $project_query = query_posts('category_name=uncategorized');
            while (have_posts()) : the_post();
                $posttags = get_the_tags();
                if ($posttags) {
                    foreach($posttags as $tag) {
                        $all_tags_arr[] = $tag -> name; //USING JUST $tag MAKING $all_tags_arr A MULTI-DIMENSIONAL ARRAY, WHICH DOES WORK WITH array_unique
                    }
                }
            endwhile;
        ?>
        <?php if ( is_array($all_tags_arr) && count($all_tags_arr) > 0 ): ?>
    <?php
        $tags_arr = array_unique($all_tags_arr); //REMOVES DUPLICATES
        foreach( $tags_arr as $tag ):
            $el = get_term_by('name', $tag, 'post_tag');
    		$arr[] = '"tag-'.$el->slug.'"';
        ?>
        <span><a href="#<?php echo $el->slug; ?>" id="taglink-tag-<?php echo $el->slug; ?>" rel="tag-<?php echo $el->slug; ?>"><?php echo $el->name; ?></a> <span class="slash">//</span></span>
    <?php endforeach; ?>
    <?php endif; ?>

Viewing 1 replies (of 1 total)
  • The topic ‘Single instance of each tag in a category?’ is closed to new replies.