• Resolved pshero

    (@pshero)


    Hey gang. I’m wondering if there’s a way to call a list of “Tags” used into a list in the archives page with each tag showing the number of posts which use it. like this:

    Tag Archive:
    > Photoshop (11)
    > Pen Tool (2)
    > Displace (3)

    etc…

    I’m using it on a standard WP archive page that also displays Monthly Archives and Category Archives.

    Any help would be GREATLY appreciated!

Viewing 8 replies - 1 through 8 (of 8 total)
  • Off hand, I don’t have the code to grab the number of posts per tag, but I do have some code that will at least get you the list of tags on your archives page: http://webtide.wordpress.com/2009/05/04/display-tags-in-3-columns/

    Thread Starter pshero

    (@pshero)

    Great script, thanks for that MMURO!

    $tags = get_tags();
    foreach ($tags as $tag) {
    echo $tag->count;
    }
    Thread Starter pshero

    (@pshero)

    Michael, Thanks for the help, but your script only returns a list of numbers… no tag names. What I’m going for is the same style as a Monthly or Category archive would be:

    Tag1 (2)
    Tag2 (16)
    Tag3 (1) etc.

    Try something like this:

    $tags = get_tags();
    foreach ($tags as $tag) {
    echo $tag->name.'('.$tag->count.')';
    }
    Thread Starter pshero

    (@pshero)

    Thanks drmanry, you got me on the right track! I’ve tried to post the code I ended up using between backticks as suggested in the comments area but every time it turned into a jumbled mess… but you definitely got me there.

    Thread Starter pshero

    (@pshero)

    Figured it out… here ya go!

    <ul>
    <?php $tags = get_tags();
    foreach ($tags as $tag) {
    echo '<li><a href="http://www.yourwebsite.com/tag/'.$tag->slug.'" rel="tag">'.$tag->name.'</a></li>';
    } ?>
     </ul>

    Mmuro,

    Thanks so much for this – I love how the 3-column looks on your sample page and am trying to implement it on a client’s wordpress site.

    I’ve copied the code into the archives.php template, but it won’t create 3 columns…is there something else…?

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Adding Tags list to the archive page’ is closed to new replies.