Okay
  Public Ticket #1245744
Change Widgets title from H2 to H4 or H5
Closed

Comments

  •  2
    kuanbc started the conversation

    Hi,

    The default Wordpress widget title (.../wp-includes/widgets.php) is assigned a H2 tag, but this is not a good seo practice (ex: we don't need a H2 "recent posts" title).

    So far I modified the codes directly in the widgets.php file, but wordpress updates will override the modification.

    Do you know what are the codes that I can put into the function.php file in the child theme to change the wordpress widget title to use H4 tag?

    Thanks.

  • [deleted] replied

    Hi kuanbc,

    We have removed many of our modifications to default ones of WordPress for SEO purposes because some users criticize us for changing the default behaviour of some WordPress elements/generators.

    So what we did is we removed the before_title and after_title from Widgets initialization.

    However if you want to add your wrapping here is what you need to do (until wordpress changes this):

    function my_custom_kalium_widgets_array( $widgets ) {
        foreach ( $widgets as $widget ) {
            $widget['before_title'] = '<h3>';
            $widget['after_title'] = '</h3>';
        }
        return $widgets;
    }
    add_filter( 'kalium_widgets_array', 'my_custom_kalium_widgets_array', 10 );

    However in v2.1.1 of Kalium the filter 'kalium_widgets_array' is not added yet, to add it just download and replace this file:

    Download this file and replace it in this directory (of the theme): /wp-content/themes/kalium/inc/functions

    After this you don't need to change any core WordPress file.

    I'd love to see this announcement of Wordpress for widget titles, because I wasn't aware of this, can you please give me any link that announces tag change for widget titles?