categories ORDER BY cat_name"; $cats = $wpdb->get_results($qrystr); // Find the max number of posts for a single category $max_value = 0; foreach ($cats as $cat) { if ($max_value < $cat->category_count) { $max_value = $cat->category_count; } } // If you want to change the appeareance of the tag cloud (maximum and minimum percentage in font-size, percentage difference between levels), change only these 3 variables $min_percentage = 80; $max_percentage = 200; $percentage_level = 10; $num_levels = ($max_percentage-$min_percentage)/$percentage_level; $postgap = $max_value / $num_levels; // Display all categories inside a div with id=cloud // Assign a class to the category (or categories) with more posts // Do not show categories without posts echo '
'; foreach ($cats as $cat) { if ($cat->category_count>0) { $catname = $cat->cat_name; $catlink = get_category_link($cat->cat_ID); $postcnt = $cat->category_count; $fontsize_percentage = $min_percentage+(Round($postcnt/$postgap)*$percentage_level); echo '\r"; } } echo "
"; ?>