Archived topic
How edit H2 To H4 in widget title?
6 replies · Started by phan cong tai on June 21, 2019

Hi there,
it requires 2 PHP filters to change them, one for the start and one for the end of the tag you can find them here:
https://docs.generatepress.com/article/generate_start_widget_title/
https://docs.generatepress.com/article/generate_end_widget_title/
I don't understand, can you explain more clearly? Which part of the theme does the code change?
So it requires PHP, this article explains the two options of adding it:
https://docs.generatepress.com/article/adding-php/
And this is the function you would add to either your child theme functions file or the codwe snippets plugin:
add_filter( 'generate_start_widget_title', 'widget_title_start_tag' );
function widget_title_start_tag()
{
return '<h4 class="widget-title">';
}
add_filter( 'generate_end_widget_title', 'widget_title_end_tag' );
function widget_title_end_tag()
{
return '</h4>';
}
Hi David,
I've the same issue.
Is it possible your code (functions.php) does not "close" correctly the <h4> ?
I've tried it on https://www.magnetmarketing.it/ but it change on h4.widget title all the footer widget text.
Thanks
Sorry David,
I just solved with:
add_filter( 'generate_start_widget_title', 'widget_title_start_tag' );
function widget_title_start_tag()
{
return '<h4 class="widget-title">';
}
add_filter( 'generate_end_widget_title', 'widget_title_end_tag' );
function widget_title_end_tag()
{
return '</h4">';
}
Thanks!
Hi there,
glad to hear that -
FYI - i corrected an error in my code here:
https://generatepress.com/forums/topic/how-edit-h2-to-h4-in-widget-title/#post-936863