Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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?

share|improve this question

2 Answers 2

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>
            <?php
            $xt++;
        }
    }
share|improve this answer

the_tags() only work within the loop;

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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