SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Thread: Show Tag Number

  1. #1
    SitePoint Enthusiast
    Join Date
    Apr 2009
    Posts
    66
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Show Tag Number

    Hello,

    I am trying to display the number of posts that have been tagged by a certain tag.

    For example, If I have 20 posts that are tagged with the tag "music". I would like to be able to call something so that it would show (20) and update as I tag more posts with the "music" tag.


    I have found this http://codex.wordpress.org/Function_...e/get_the_tags

    and at the very bottom it mentions
    count
    number of uses of this tag, total
    but I can not figure out how to use it.


    Could any one lend a hand?

    Thank you very much!!

  2. #2
    The knight who said ni! RockyShark's Avatar
    Join Date
    Apr 2003
    Location
    Rockhampton, Australia
    Posts
    701
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Something like this?

    PHP Code:
    foreach (get_the_tags() as $tag){
      echo 
    "<li>";
      echo 
    get_tag_link($tag->term_id);
      echo 
    get_tag_link($tag->count);
      echo 
    "</li>";

    I haven't tried this - just checked the codex and modified their example a bit.

    Does that help?

  3. #3
    SitePoint Enthusiast
    Join Date
    Apr 2009
    Posts
    66
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    RockyShark,

    Thank you for trying!

    I do not think the code produces the desired results.

    It outputs a list of the urls of all of the tags on the current post.


    I currently use
    PHP Code:
    get_usernumposts($userid_here)); ?> 
    to display the number of posts a certain user has.

    I was hoping to find something like
    PHP Code:
    get_tagnumposts($tagid_here)); ?> 
    My goal is to be able to see how many times a certain tag is used in my entire site from a static page.


    Do you happen to have any ideas? I thought that the "count" function in my previous post might be it, but I am not sure.


    Thank you for your help!!! I greatly appreciate it.

  4. #4
    The knight who said ni! RockyShark's Avatar
    Join Date
    Apr 2003
    Location
    Rockhampton, Australia
    Posts
    701
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ah, okay. I misunderstood your question.

    That function only applies to tags attached to a specific post I think.

    I was thinking you might be able to use this: http://codex.wordpress.org/Template_Tags/wp_tag_cloud - and choose 'format' => 'list' - that will give you a list of tags used sitewide, and you can order them by count, but it doesn't seem to be able to output the count.

    Dunno...


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •