Archived topic
Change code for widget titles
9 replies · Started by morriscountynj on April 11, 2017
Right now, widgets default to <h4> tags.
For accessibility reasons (headers should really only be used for actual headers of a section of content, and in that case need to be nested properly; widget titles aren't in the page flow) I'd like to change that to <p> tags. How would I go about doing that?
Hi there,
You can use the following two filters:
https://docs.generatepress.com/article/generate_start_widget_title/
https://docs.generatepress.com/article/generate_end_widget_title/
Let me know if you need more info :)
perfect, thank you :)
You're welcome :)
hello,
ok for the h4 on sidebar with the filter "generate_start_widget_title" and "generate_end_widget_title" but where is the filetr for the h4 on the footer ?
i don't found : https://docs.generatepress.com/collection/filters/
All widgets in GP use the same filter.
this code is correct ?
add_filter( 'generate_start_widget_title','generate_remove_widget_title_h4' );
function generate_remove_widget_title_h4()
{
return '<span class="widget-title-side">';
}
add_filter( 'generate_end_widget_title','generate_remove_widget_title_end_h4' );
function generate_remove_widget_title_end_h4()
{
return '</span>';
}
Yep, looks good to me.
Hello Tom
Sorry if I reopen a old topic, but is for the same think I want to change the title widget to h4 my SEO consultant recommended that to me.
Is this code correct?
add_filter( 'generate_start_widget_title','h2_to_h4' );
function h2_to_h4()
{
return '<h4 class="widget-title" /h4>';
}
and I put it on a functions.php is that OK?
Thanks
This should be the exact code you need:
https://generatepress.com/forums/topic/changing-sidebar-h-tags/page/2/#post-711983