Widget Title change h2 to h4

cmsexpertss
cmsexpertss
20 Apr 2021

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

Was this article helpful?

Tags

Categories

Never miss new post again

Subscribe and get list of new posts in your inbox

Click to Copy