• Resolved nitm

    (@nitm)


    Hi.

    I’m trying to show the tag cloud in different ways:
    – when in index.php show all of the tags
    – when in category.php show tags of the category only (‘taxonomy’ => ‘category’)
    – when in single.php show the tags of the current post only

    What I get now is that in the category view it works as I want, in the other two cases I see all the tags.
    From what I understand ‘taxonomy’ => ‘post_tag’ should show just the tags in the current post, but from some reason it doesn’t filter.

    What am I missing?
    Thanks!

Viewing 6 replies - 1 through 6 (of 6 total)
  • I don’t have the answer to your actual question to hand but, in the single post, why not just use the_tags()?

    Thread Starter nitm

    (@nitm)

    Because I want the “cloud” look where they have different sizes depending on popularity and such, and from what I tested the_tags just outputs a list of them.

    Ah – now I understand! You’re using wp_tag_cloud, yes. If so, I think you’ve misunderstood the taxonomy attribute.

    By post_tags, it refers to the taxonomy type post_tags – not the tags for this post. The taxonomy attribute has been added so that people can have a cloud of category links (‘taxonomy’ => ‘category’) or blogroll links ((‘taxonomy’ => ‘link_category’) or a completely new custom taxonomy. In each case, the displayed cloud will be generated from all of the relevant types (categories, links etc) even when on a single post page.

    Does that help at all?

    Thread Starter nitm

    (@nitm)

    I was guessing that the whole taxonomy thing is escaping me..
    So, there’s no way to display just the tags added to the single post in a cloud style other than implementing it myself?

    possibly:

    <?php if( is_single() ) :
    $tags = implode(',',wp_get_post_tags($post->ID,array('fields'=>'ids')));
    wp_tag_cloud('include='.$tags);
    endif;
    ?>

    http://codex.wordpress.org/Function_Reference/wp_get_post_tags
    http://codex.wordpress.org/Function_Reference/wp_tag_cloud

    Thread Starter nitm

    (@nitm)

    yes!
    exactly what I wanted.
    thanks a lot.

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘wp_tag_cloud’ is closed to new replies.