How To Customize WordPress Widget Titles With Filter

Adding this snippet to the functions.php will let you use a filter to replace the widget title with custom title and or html.

add_filter ( 'widget_title', 'wpmazing_add_span_widgets' );
function wpmazing_add_span_widgets( $old_title ) {

$title = explode( " ", $old_title, 2 );

if ( isset( $title[0] ) && isset( $title[1] ) ) {
$titleNew = "$title[0] $title[1]";
}
else {
return;
}

return $titleNew;
}
0SHARES
0
0

Comments