WordPress.org

Support

Support » Plugins and Hacks » Hacks » [Resolved] the_tags show description

[Resolved] the_tags show description

  • I have been trying to figure out how to show the tag’s description in the loop on my index.php page. I’ve made extensive use of Google with no solution yet.

    My Code
    <hgroup><?php the_tags('<h3>Authors:</h3><h2>','</h2><h2>','</h2>'); ?></hgroup>

    Basic stuff. That works but when I try to add things below my tags don’t show up at all.
    <?php if (is_tag()) { ?><?php echo tag_description(); ?><?php } ?>

    <?php if (is_tag()) { ?><h2><?php echo tag_description(); ?></h2><?php } ?>

    To sum up what I’m looking for. Show all tags’ description listed in a post below the tag. A format may look like this.

    <h2>Tag 1</h2>
    <p>Tag 1 Description</p>

    Anyone know about a plugin or any code that can help me?

Viewing 3 replies - 1 through 3 (of 3 total)
  • esmi

    @esmi

    Forum Moderator

    I’ve read that entire page before and after you posted. Maybe I’m missing something but I don’t see anything there that help’s me modify the_tags code to show a Tag’s description.

    I did read about adding:
    <?php } else if ($this_tag->name == "someothertag" ) { ?>

    This would require me to go back and add this statement for every tag I create which will be a daunting task once my tag database becomes really large.

    Is there a simpler solution? One which would just show all descriptions for every tag in the loop?

    Kaiser from Stackexchange was able to solve this issue for me.
    http://wordpress.stackexchange.com/users/385/kaiser

    $tags = get_the_tags(); // for the specific post
    // $tags = get_tags(); // all tags
    $html = '<div class="post_tags">';
    foreach ( $tags as $tag )
    {
        $tag_link = get_tag_link( $tag->term_id );
    
        $html .= "Describtion for ".ucfirst( strtolower( $tag->name ) ).": $tag->description";
        $html .= "<a href='{$tag_link}' title='{$tag->name} Tag' class='{$tag->slug}'>{$tag->name}</a>";
        }
    
    $html .= '</div>';
    echo $html;
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Resolved] the_tags show description’ is closed to new replies.