WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] return tags with more than 5 posts (4 posts)

  1. gerald@WPcustoms
    Member
    Posted 3 years ago #

    Hello,

    I call the tags this way:

    <?php
    $tags = get_tags();
    foreach (get_tags() as $tag){
    	$tag_link = get_tag_link($tag->term_id);
    	$html .= "<li><a href='{$tag_link}/' title='{$tag->name} Tag' >{$tag->name}</a>($tag->count)</li>";
    echo $html;
    ?>

    now this code returns all tags but I only want to display the tags which have more than 5 posts. Can somebody please help me with this?
    Thanks in advance
    Regards,
    geeman

  2. vtxyzzy
    Member
    Posted 3 years ago #

    I think this is what you want:

    <?php
    $tags = get_tags();
    foreach (get_tags() as $tag){
       if ($tag->count < 6) continue;
       $tag_link = get_tag_link($tag->term_id);
       $html .= "<li><a href='{$tag_link}/' title='{$tag->name} Tag' >{$tag->name}</a>($tag->count)</li>";
    }
    echo $html;
    ?>
  3. gerald@WPcustoms
    Member
    Posted 3 years ago #

    works like a charm!
    thanks a lot for this solution :)

  4. Rev. Voodoo
    Volunteer Moderator
    Posted 3 years ago #

    Yoink....that's good code if I may chime in. Thanks for enhancing my archive page even more!

Topic Closed

This topic has been closed to new replies.

About this Topic