It is necessary to display all tags available in WP, using the wp_tag_cloud() function or its subfunctions, adding to each class tag from "c1" to "c10" (depending on the number of records in the tag), in order to later color this cloud through CSS .

I found such functionality only in the plugin "Simple Tags", but with an attendance of 5,000 people a day, it eats the CPU 100%. And to pull out the necessary code from it, I did not have enough knowledge.

Please tell me how this can be implemented.

  • You can add the necessary js classes. - pepel_xD

1 answer 1

We need to get the values ​​of the labels in the array and process it. For example:

 $cloud = wp_tag_cloud("echo=false&format=array"); foreach ($cloud as &$tag) { $pos = strpos($tag, "title='"); $title = substr($tag, $pos + 7); $pos = strpos($title, " "); $add_class = "c" . substr($title, 0, $pos); $tag = str_replace("class='", "class='" . $add_class . " ", $tag); echo $tag; } 
  • The option is not bad, only you need to take not the number of entries in the tag, but the font-size value - Leonid Ozerny
  • so in the question it was voiced just the number of entries in the tag)) - KAGG Design