Remove title attribute from tag cloud widget [duplicate]

Why did you think that code would work? There is no hook named wp_widget_tag_cloud that I can find, and there is no hook specifically meant for altering that attribute. But you can pass a topic_count_text_callback to wp_tag_cloud, which is what generates the tag cloud for the widget, and there is a hook that allows you to alter the widget’s tag cloud arguments.

function tag_count_cb($count) {
  return 'test';
}

function remove_tag_title_attributes($args) {
  $args['topic_count_text_callback'] = 'tag_count_cb';
    var_dump($args);
  return $args;
}
add_filter('widget_tag_cloud_args', 'remove_tag_title_attributes');

But you don’t have much to work with– just the tag count. To get more to work with you will need to do something more like what you trying but with a different regex and a different hook.

function tag_cloud_attribute_rebuild($match) {
  $a = "<a href="https://wordpress.stackexchange.com/questions/107249/%s" class="https://wordpress.stackexchange.com/questions/107249/%s" title="https://wordpress.stackexchange.com/questions/107249/%s" style="https://wordpress.stackexchange.com/questions/107249/%s">%s</a>";
  return sprintf(
    $a,
    $match[1],
    $match[2],
    $match[3],
    $match[4],
    $match[5]
  );
}

function remove_tag_title_attributes($output) {
  $pattern = "|<a href="([^"]*?)' class="([^"]*?)' title="([^"]*?)' style="([^"]*?)'>([^<]*)</a>|";
  $output = preg_replace_callback($pattern,'tag_cloud_attribute_rebuild',$output);
  return $output;
}
add_filter('wp_tag_cloud', 'remove_tag_title_attributes');

The title is $match[3]. The other information is to give you some information to work with. Alter $match[3] before the sprintf. If that isn’t enough information you will have to extract the ID from $match[2] or use the tag name in $match[5] and run a query, but that will be very labor intensive for the server.

That is how you would do it with the Core widget. Another option would be to rebuild the widget under a different name– that is, make your own widget using the Core widget as a model–and include altered versions of whatever functions you need.