Skip to content

Instantly share code, notes, and snippets.

@DaDlugosch
Forked from dylanjameswagner/tag-cloud.php
Created March 2, 2021 13:24
Show Gist options
  • Select an option

  • Save DaDlugosch/6b962d2b366149a6818300572f692d68 to your computer and use it in GitHub Desktop.

Select an option

Save DaDlugosch/6b962d2b366149a6818300572f692d68 to your computer and use it in GitHub Desktop.

Revisions

  1. @dylanjameswagner dylanjameswagner created this gist May 3, 2017.
    14 changes: 14 additions & 0 deletions tag-cloud.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    function carbon_tag_cloud_class_active($tags_data) {

    $body_class = get_body_class();

    foreach ($tags_data as $key => $tag) {
    if(in_array('tag-'.$tag['id'], $body_class)) {
    $tags_data[$key]['class'] = $tags_data[$key]['class'] ." active-tag";
    }
    }

    return $tags_data;
    }

    add_filter('wp_generate_tag_cloud_data', 'carbon_tag_cloud_class_active');