Skip to content

Instantly share code, notes, and snippets.

@DaDlugosch
DaDlugosch / tag-cloud.php
Created March 2, 2021 13:24 — forked from dylanjameswagner/tag-cloud.php
Add an active class to the current tag in a tag cloud widget.
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";
}
}