Ready to get started?Download WordPress


Tag Cloud Does Not Display in Ascending Alphanumeric Order (2 posts)

  1. sassymonkey
    Posted 5 years ago #

    I have a kind of tag cloud box that displays all linked tags from the current set of posts.

    I can't figure out how to sort the tags in ascending alphanumeric order. The tags are all jumbled together without any apparent organization.

    Can anyone help? Here's the code:

    <ol id="tagsSubNav"><li>Sort by Type:</li><?php
    		if (have_posts()) : while (have_posts()) : the_post();
    		   $posttags = get_the_tags();
    			if ($posttags) {
    				foreach($posttags as $tag) {
    					$all_tags_arr[] = $tag -> name; //USING JUST $tag MAKING $all_tags_arr A MULTI-DIMENSIONAL ARRAY, WHICH DOES WORK WITH array_unique
    		endwhile; endif; 
    		$tags_arr = array_unique($all_tags_arr); //REMOVES DUPLICATES
    		//echo '<pre>'.print_r($tags_arr, true).'</pre>';
    		  foreach ($tags_arr as $tag) {
    			 echo '<li><a href="/tag/'.$tag.'">'.$tag.'</a></li>';
  2. sassymonkey
    Posted 5 years ago #

    Oh yes, here's an example of the box near the top of the center content column:


Topic Closed

This topic has been closed to new replies.

About this Topic