0

So I had to fiddle allot with tag cloud to display it correctly. My script limits display to 5, and since I don't display all tags, I'd like wp to output list in descending order based on popularity. So if tag has most posts it will be displayed first, and so on... Is this possible? I have a hunch I've to modify get_the_tags(), but not sure how as of now... any help appreciated! :)

                        <?php

                    rewind_posts();
                    while (have_posts()) : the_post();

                    $posttags = get_the_tags();
                    $counttag=0;
                    if ($posttags) {
                        foreach($posttags as $tag) {
                            $counttag++;
                            echo '<li><a href="'.get_tag_link($tag->term_id).'">'.$tag->name.'</a></li> ';
                            if( $counttag >5 ) break;
                        }
                    }

                    endwhile;

                    ?>
  • nobody? really? – user8842 Sep 23 '11 at 14:48
  • WordPress has function wp_tag_could() maybe you should try output tag cloud with it – Mamaduka Sep 24 '11 at 13:50
  • wp_tag_could() I cannot make it target particular post. it rather outputs all /most popular tags from the whole blog. I want post specific tags to be displayed. – user8842 Sep 26 '11 at 14:11
0

This is a little bit more complicated than I thought.

But I did find this link Which should help you on your path. Minus the custom post types, the code should be what you are looking for.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy