How to change the widget HTML by a child WordPress theme

Questo articolo รจ stato scritto oltre 1 years, il contenuto potrebbe essere datato.

This is very simple and you can do it in this way:

add_filter('dynamic_sidebar_params', 'yourtheme_change_widget_head');

function yourtheme_change_widget_head( $params ) {
    if ( $params[0]['id'] === 'footer-sidebar-2' ) {
        $params[0]['before_title'] = '<h4 class="widget-title">';
        $params[0]['after_title'] = '</h4>';
    }
    return $params;
}

This filter allows you to check what is executed by dynamic_sidebar as parameter.
So first of all you need to check what is the sidebar you want to alter and later the parameter that you want to change.

Where to put it? In the functions.php of your child theme.

Liked it? Take a second to support Mte90 on Patreon!
Become a patron at Patreon!

Leave a Reply

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