WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using a little function below to list out the post_terms. The function is outputting very specific markup for the grouping, filter, and href attributes (this is a term selector for the jQuery isotope plugin).

$terms = get_terms("post_tag");
$count = count($terms);
 if($count > 0){
    echo '<div class="option-combo tag">';
    echo '<h4>Post Tags</h4>';
    echo '<ul class="filter option-set floated clearfix">';
    echo '<li><a href="#filter-tag-any" data=filter="" data-group="tag" class="selected">any</a>';
    foreach ($terms as $term) {
        echo '<li><a href="#filter-tag-'.$term->slug.'" data-group="tag" data-filter=".tag-'.$term->slug.'">'.$term->name.'</a>';        
    echo '</ul>';
    echo '</div>';


Given the requirements above where each term has it's own custom href, data-group, data-filter, how would I go about changing this list format into a tag cloud with my requirements?

(an ordered list of terms is way to long for use within a sidebar, hence a tag cloud would work much better when using terms as a selector)

I did look through the codex, but didn't see any examples on how to modify the output of the tag cloud.


share|improve this question
sorry about the code format above, I've tried everything to make it look right but it wont. I've tried 4spaces, backticks, etc.... rather confusing – shawn May 12 '11 at 19:01
I edited the styling in the code – MZAweb May 12 '11 at 20:01
up vote 1 down vote accepted

This is how the links are created in wp_generate_tag_cloud (wp-includes/category-template.php)

foreach ( $tags as $key => $tag ) {
    $count = $counts[ $key ];
    $real_count = $real_counts[ $key ];
    $tag_link = '#' != $tag->link ? esc_url( $tag->link ) : '#';
    $tag_id = isset($tags[ $key ]->id) ? $tags[ $key ]->id : $key;
    $tag_name = $tags[ $key ]->name;
    $a[] = "<a href='$tag_link' class='tag-link-$tag_id' title='" . esc_attr( call_user_func( $topic_count_text_callback, $real_count ) ) . "' style='font-size: " .
        ( $smallest + ( ( $count - $min_count ) * $font_step ) )
        . "$unit;'>$tag_name</a>";

There seems not to be a way to do what you need. Maybe copying all wp_generate_tag_cloud and modifying it to your needs in your functions.php?

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.