Wordpress Widget Title change from H1 to H3 or H4

I have done a crawl on my website using screaming frog and found out that each page has at least 6 H1's

I was hoping someone could tell me a way to change this from H1 to a lesser H, maybe H3.

I tried inserting into funchtions.php:

add_action( 'after_setup_theme', 'remove_parent_theme_features', 10 );

function remove_parent_theme_features() {
    remove_action( 'init', 'sempress_widgets_init' );
    add_action( 'init', 'ph_sempress_widgets_init' );
}

function ph_sempress_widgets_init() {
  register_sidebar( array(
    'name' => __( 'Sidebar 1', 'sempress' ),
    'id' => 'sidebar-1',
    'before_widget' => '< section id="%1$s" class="widget %2$s">',
    'after_widget' => '< /section>',
    'before_title' => '< h3 class="widget-title">',
    'after_title' => '< /h3>',
  ) );
}

It has an effect but rather than changing the title to H3, it shows the lines of code

i.e:

< /section>< section id="woocommerce_layered_nav-3" class="widget woocommerce widget_layered_nav woocommerce-widget-layered-nav">< h3 class="widget-title">Favourite Brand?< /h3>

rather that just showing Favourite brand.

Can anyone see any way I can tweak the above so it works properly?

1 answer

  • answered 2018-01-11 21:31 Paul Shipley

    Have you tried removing the extra spaces on the html tags?

    register_sidebar( array(
        'name' => __( 'Sidebar 1', 'sempress' ),
        'id' => 'sidebar-1',
        'before_widget' => '<section id="%1$s" class="widget %2$s">',
        'after_widget' => '</section>',
        'before_title' => '<h3 class="widget-title">',
        'after_title' => '</h3>',
    ) );
    

    https://github.com/pfefferle/SemPress/blob/master/sempress/functions.php