WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. sassymonkey
    Member
    Posted 4 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
    		query_posts('category_name=retail&showposts=-1&orderby=title&order=asc');
    		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>';
    		  }
    
    		?></ol>
  2. sassymonkey
    Member
    Posted 4 years ago #

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

    http://railroad.server296.com/retail/

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags