function get_community_tag_cloud( $display = false, $limit = 50, $font_size = 20 ) { global $wpdb; // Get all blogs $sites = $wpdb->get_results( "SELECT blog_id FROM wp_blogs", OBJECT); $array_tags = array(); // Set category to not display, usually 'Uncategorized' $no_category = "Sin Categorizar"; foreach($sites as $site){ $table_tags = "wp_".$site->blog_id."_terms"; $table_taxonomy = "wp_".$site->blog_id."_term_taxonomy"; if($exists = $wpdb->get_row("show tables like '$table_tags'")){ // Get name and count for each post_tag $tag_results = $wpdb->get_results("SELECT name, count FROM $table_tags INNER JOIN $table_taxonomy ON $table_tags.term_id = $table_taxonomy.term_id WHERE $table_taxonomy.taxonomy LIKE 'post_tag'"); foreach ($tag_results as $tag) { if( strlen($tag->name) > 0 and $tag->name != $no_category){ // Increment count of this tag $array_tags[$tag->name] += $tag->count; } } } } // Sort tag array by 'popularity' arsort($array_tags, SORT_NUMERIC); // Limit size if necessary if(count($array_tags) > $limit){ $array_tags = array_slice($array_tags, 0, $limit); } // Display options if( $display == true ){ if( is_array( $array_tags ) ) { reset( $array_tags ); echo "
"; foreach ( (array) $array_tags as $name => $count ) { $url = get_site_option('url')."/tags/$name"; echo "$name "; if($font_size > 8){ $font_size--; } } echo "
"; } } return $array_tags; }