3

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.

3

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' );
  • 1
    Excellent, gave you the big 25! – Dev Apr 14 '17 at 15:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.