wp_tag_cloud() and the_taxonomies() work in a widget I built but I can not get the_tags() to work.

I want to display the tags assigned to the current post. I built a widget to do this. the widget works fine but as I mentioned, wp_tag_cloud() and the_taxonomies() will display.

I have tried every possible code snippet I could find.

Whats happening and do I display the posts tags?

2 Answers 2


the_tags() only work within the loop;

possibly try to use wp_get_post_tags() where you can pass the post ID


I could not see the forest between the trees.

I was dealing with a custom taxonomy and solved the problem with get_the_terms().

    $kw_tags = '';
    $tags    = get_the_terms( $pid, 'place_tags' );
    $xt          = 1;

    if ($tags && ! is_wp_error($tags)) {
        ?><h4><?php echo get_option('tag_cloud_title'); ?></h4><?php
        foreach ($tags as $tag) {
            $kw_tags = $tag->name;
            <span class="tag-widget"><a href="<?php ?>" title="<?php ?>"><?php echo $kw_tags; ?></a></span>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.