Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End Adding span to WordPress widget title Reply To: Adding span to WordPress widget title

#236432
jmstopper
Participant

Hi TWG

This should do the job. It uses the wordpress widget title filter which provides the widget title as a parameter. From there you can modify the title and return it once your happy.

Documentation can be found at https://codex.wordpress.org/Plugin_API/Filter_Reference/widget_title

function custom_widget_title($title) {
$temp = explode(' ', $title);
$temp[0] = '<span>' . $temp[0] . '</span>';
$title = implode(' ', $temp);
return $title;
}
add_filter('widget_title', 'custom_widget_title');