This code i wrote works but it doesn’t remove the h4

add_filter( 'widget_title','modify_text_widget_title_tags', 10, 3 );

function modify_text_widget_title_tags( $title, $instance, $id_base ) {

    if ( 'text' == $id_base ) 

    return '<h2 class="widget-title widgettitle">' . $title . '</h2>';

}

It does output h2 but i need to filter the h4 tags and replace them with h2.

I looked in class-wp-widget-text.php but there is no filter for the widget title wrapping tags or any div class which wraps the widget title.

1 Answer
1

The filter to do this is dynamic_sidebar_params also see this tutorial on this filter at ACF’s site (even if you don’t use ACF).

function prefix_filter_widget_title_tag( $params ) {

    $params[0]['before_title'] = '<h2 class="widget-title widgettitle">' ;

    $params[0]['after_title']  = '</h2>' ;

    return $params;

}
add_filter( 'dynamic_sidebar_params' , 'prefix_filter_widget_title_tag' );

Leave a Reply

Your email address will not be published. Required fields are marked *