WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Adding Tags list to the archive page (9 posts)

  1. pshero
    Member
    Posted 5 years ago #

    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!

  2. 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/

  3. pshero
    Member
    Posted 5 years ago #

    Great script, thanks for that MMURO!

  4. MichaelH
    Member
    Posted 5 years ago #

    $tags = get_tags();
    foreach ($tags as $tag) {
    echo $tag->count;
    }
  5. pshero
    Member
    Posted 5 years ago #

    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.

  6. drmanry
    Member
    Posted 5 years ago #

    Try something like this:

    $tags = get_tags();
    foreach ($tags as $tag) {
    echo $tag->name.'('.$tag->count.')';
    }
  7. pshero
    Member
    Posted 5 years ago #

    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.

  8. pshero
    Member
    Posted 5 years ago #

    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>
  9. thewebwriter
    Member
    Posted 5 years ago #

    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...?

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.