WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] List tags and sort by number of posts with that tag

[Resolved] List tags and sort by number of posts with that tag

  • Hi all!
    I’ve been strugling with this for a while now, but cant figure it out. Guess its more of a php question then wp..

    Ok. I want to List all my tags and i want to order them by the ammount of posts that has the tag.
    This is what i got so far:

    $tags = get_tags();
    			$tags_count = count($tags);
    			$top = 15;
    			//$tags[$i]->count
    			for ($i = 0;$i < $tags_count;$i++):
    			$slug = $tags[$i]->slug;
    			if ($i < $top){
    			echo "<li><a href='".get_tag_link($tags[$i]->term_id)."'>".$slug."</a></li>";

    The reason for $top is that after 15 tags listed im hiding the others, displaying them when user want to view more.

    So, could anyone point me to how to resolve this?! Would be awesome. I know how to count the posts for each tag. But not ho to sort by it!

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Resolved] List tags and sort by number of posts with that tag’ is closed to new replies.
Skip to toolbar