[Resolved] Change code for widget titles

Home Forums Support [Resolved] Change code for widget titles

Home Forums Support Change code for widget titles

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #304628
    morriscountynj

    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?

    #304742
    Tom
    Lead Developer
    Lead Developer

    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 πŸ™‚

    #304930
    morriscountynj

    perfect, thank you πŸ™‚

    #305062
    Tom
    Lead Developer
    Lead Developer

    You’re welcome πŸ™‚

    #308129
    Thierry

    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/

    #308207
    Tom
    Lead Developer
    Lead Developer

    All widgets in GP use the same filter.

    #308217
    Thierry

    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>';
    }
    #308223
    Tom
    Lead Developer
    Lead Developer

    Yep, looks good to me.

    #716859
    Fernando

    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

    #716888
    Leo
    Staff
    Customer Support
Viewing 10 posts - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.