Deprecated: Function seems_utf8 is deprecated since version 6.9.0! Use wp_is_valid_utf8() instead. in /home/dplugins-code/htdocs/code.dplugins.com/wp-includes/functions.php on line 6131

Deprecated: Function seems_utf8 is deprecated since version 6.9.0! Use wp_is_valid_utf8() instead. in /home/dplugins-code/htdocs/code.dplugins.com/wp-includes/functions.php on line 6131
Widget Title change h2 to h4 – Code DPlugins

Widget Title change h2 to h4

WordPress Widgets by default have titles as h2 tag. if you need to change them to something else it is easy to change ti with WordPress filter.

screenshot 2021 05 09 at 19.32.39
<?php

function change_widget_title($title, $instance, $id_base) {
	$title = '<h4 class="widget-title widgettitle">'.preg_replace('/[^A-Za-z0-9\-]/', '', strip_tags($title)).'</h4>';
      return $title;
    }

add_filter('widget_title' , 'change_widget_title', 10, 3); //we use the default priority 

?>  


Add Code Snippet

Open Scripts Organizer

Hit Add new.

screenshot 2021 04 15 at 21.25.39

Scripts Organizer Settings

Trigger Location: Everywhere
Script Location: PHP

screenshot 2021 04 15 at 21.29.12 1
Click to Copy