• Resolved downfast

    (@downfast)


    The following shows me all tags names based on all posts, which means I end up with a list with duplications. How do I stop it so that it only shows me unique tags?

    <ul>
                <?php
                    query_posts('category_name=html');
                    if (have_posts()) : while (have_posts()) : the_post();
    
                        if( get_the_tag_list() ){
                            echo $posttags = get_the_tag_list('<li>','</li><li>','</li>');
                        }
                    endwhile; endif;
                    wp_reset_query();
                ?>
       </ul>

    Any help please?

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

    (@downfast)

    The solution

    <ul>
        <?php
            query_posts('category_name=YOU CAT NAME');
            if (have_posts()) {
    
                $tags = array();
    
                while(have_posts()) {
                    the_post();
                    if(get_the_tag_list()) {
                        foreach(wp_get_post_tags(get_the_ID()) as $tag) {
                            $allTags[$tag->term_id] = $tag;
                        }
                    }
                }
    
                foreach($tags as $tag) {
                    echo '<li><input class="checkTag" type="checkbox" value="' . $tag->name . '" />' . '&nbsp;&nbsp;' . $tag->name . '</li>';
                }
            }
            wp_reset_query();
        ?>
    </ul>
Viewing 1 replies (of 1 total)
  • The topic ‘Show only unique tags’ is closed to new replies.