How to check if widget has automatic title

Any widgets written to operate as the Core “Recent Posts” widget does can be forced to skip the title by a filter on widget_title:

function widget_title_hack_191120($title, $instance) {
  if (empty($instance['title'])) {
    $title="";
  }
  return $title;
}
add_filter('widget_title','widget_title_hack_191120', 10, 2);

I don’t know if there is a generic solution to the problem. Any widget could avoid this simply by not using the widget_title filter.

Leave a Comment