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.


  • 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
    Commented May 12, 2011 at 19:01
  • I edited the styling in the code
    – MZAweb
    Commented May 12, 2011 at 20:01

1 Answer 1


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?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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