Forums

[resolved] Display Post count with single Tag (5 posts)

  1. moe233
    Member
    Posted 4 months ago #

    Hello,

    I need to display a single tag and the post count associated with it. For example,

    Summer (4)

    Thanks for assistance

  2. MichaelH
    moderator
    Posted 4 months ago #

    Untested

    <?php
    //assuming your tag id is 44
    $tags = get_tags('include=44');
    if ($tags) {
    foreach ($tags as $tag) {
    echo '<p>Tag: ' . $tag->name  . '(' . $tag->count . ')</p>';
    }
    }
    ?>
  3. moe233
    Member
    Posted 4 months ago #

    Exactly what I wanted!

    Thanks

    I just modified the echo line to create a link to the tag posts (borrowed from http://wordpress.org/support/topic/230594 posted by you)

  4. davebowker
    Member
    Posted 4 months ago #

    This is great for doing each tag individually, but how about if we wanted to display a tag cloud with the post count on each tag.

    Example, Summer (4), Spring (19), Autumn (7), Winter (2) ...etc...

    I looked but there doesn't seem to be a show_count option on the tags like there is on the categories.

    Thanks.

  5. MichaelH
    moderator
    Posted 4 months ago #

    The reason for a cloud is to let the size 'describe' the approximate number of results for each entry in the cloud.

Reply

You must log in to post.

About this Topic