Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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>';
 }

Question:

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.

thanks

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
add comment

1 Answer 1

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
add comment

Your Answer

 
discard

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.