Home › Forums › Back End › Adding span to WordPress widget title › Reply To: Adding span to WordPress widget title
January 5, 2016 at 9:25 pm
#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');